new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")() ? RegExp.prototype.split : require("./shim");
|
||||
@@ -0,0 +1,913 @@
|
||||
<script>
|
||||
import {
|
||||
beforeUpdate,
|
||||
createEventDispatcher,
|
||||
onDestroy,
|
||||
onMount,
|
||||
tick
|
||||
} from "svelte";
|
||||
import List from "./List.svelte";
|
||||
import ItemComponent from "./Item.svelte";
|
||||
import SelectionComponent from "./Selection.svelte";
|
||||
import MultiSelectionComponent from "./MultiSelection.svelte";
|
||||
import isOutOfViewport from "./utils/isOutOfViewport";
|
||||
import debounce from "./utils/debounce";
|
||||
import DefaultClearIcon from "./ClearIcon.svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
export let container = undefined;
|
||||
export let input = undefined;
|
||||
export let Item = ItemComponent;
|
||||
export let Selection = SelectionComponent;
|
||||
export let MultiSelection = MultiSelectionComponent;
|
||||
export let isMulti = false;
|
||||
export let multiFullItemClearable = false;
|
||||
export let isDisabled = false;
|
||||
export let isCreatable = false;
|
||||
export let isFocused = false;
|
||||
export let selectedValue = undefined;
|
||||
export let filterText = "";
|
||||
export let placeholder = "Select...";
|
||||
export let items = [];
|
||||
export let itemFilter = (label, filterText, option) =>
|
||||
label.toLowerCase().includes(filterText.toLowerCase());
|
||||
export let groupBy = undefined;
|
||||
export let groupFilter = groups => groups;
|
||||
export let isGroupHeaderSelectable = false;
|
||||
export let getGroupHeaderLabel = option => {
|
||||
return option.label;
|
||||
};
|
||||
export let getOptionLabel = (option, filterText) => {
|
||||
return option.isCreator ? `Create \"${filterText}\"` : option.label;
|
||||
};
|
||||
export let optionIdentifier = "value";
|
||||
export let loadOptions = undefined;
|
||||
export let hasError = false;
|
||||
export let containerStyles = "";
|
||||
export let getSelectionLabel = option => {
|
||||
if (option) return option.label;
|
||||
};
|
||||
|
||||
export let createGroupHeaderItem = groupValue => {
|
||||
return {
|
||||
value: groupValue,
|
||||
label: groupValue
|
||||
};
|
||||
};
|
||||
|
||||
export let createItem = filterText => {
|
||||
return {
|
||||
value: filterText,
|
||||
label: filterText
|
||||
};
|
||||
};
|
||||
|
||||
export let isSearchable = true;
|
||||
export let inputStyles = "";
|
||||
export let isClearable = true;
|
||||
export let isWaiting = false;
|
||||
export let listPlacement = "auto";
|
||||
export let listOpen = false;
|
||||
export let list = undefined;
|
||||
export let isVirtualList = false;
|
||||
export let loadOptionsInterval = 300;
|
||||
export let noOptionsMessage = "No options";
|
||||
export let hideEmptyState = false;
|
||||
export let filteredItems = [];
|
||||
export let inputAttributes = {};
|
||||
export let listAutoWidth = true;
|
||||
export let itemHeight = 40;
|
||||
export let Icon = undefined;
|
||||
export let iconProps = {};
|
||||
export let showChevron = false;
|
||||
export let showIndicator = false;
|
||||
export let containerClasses = "";
|
||||
export let indicatorSvg = undefined;
|
||||
export let ClearIcon = DefaultClearIcon;
|
||||
|
||||
let target;
|
||||
let activeSelectedValue;
|
||||
let _items = [];
|
||||
let originalItemsClone;
|
||||
let prev_selectedValue;
|
||||
let prev_listOpen;
|
||||
let prev_filterText;
|
||||
let prev_isFocused;
|
||||
let prev_filteredItems;
|
||||
|
||||
async function resetFilter() {
|
||||
await tick();
|
||||
filterText = "";
|
||||
}
|
||||
|
||||
let getItemsHasInvoked = false;
|
||||
const getItems = debounce(async () => {
|
||||
getItemsHasInvoked = true;
|
||||
isWaiting = true;
|
||||
|
||||
let res = await loadOptions(filterText).catch(err => {
|
||||
console.warn('svelte-select loadOptions error :>> ', err);
|
||||
dispatch("error", { type: 'loadOptions', details: err });
|
||||
});
|
||||
|
||||
if (res && !res.cancelled) {
|
||||
if (res) {
|
||||
items = [...res];
|
||||
dispatch("loaded", { items });
|
||||
} else {
|
||||
items = [];
|
||||
}
|
||||
|
||||
isWaiting = false;
|
||||
isFocused = true;
|
||||
listOpen = true;
|
||||
}
|
||||
|
||||
}, loadOptionsInterval);
|
||||
|
||||
$: disabled = isDisabled;
|
||||
|
||||
$: updateSelectedValueDisplay(items);
|
||||
|
||||
$: {
|
||||
if (typeof selectedValue === "string") {
|
||||
selectedValue = {
|
||||
[optionIdentifier]: selectedValue,
|
||||
label: selectedValue
|
||||
};
|
||||
} else if (isMulti && Array.isArray(selectedValue) && selectedValue.length > 0) {
|
||||
selectedValue = selectedValue.map(item => typeof item === "string" ? ({ value: item, label: item }) : item);
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if (noOptionsMessage && list) list.$set({ noOptionsMessage });
|
||||
}
|
||||
|
||||
$: showSelectedItem = selectedValue && filterText.length === 0;
|
||||
|
||||
$: placeholderText = selectedValue ? "" : placeholder;
|
||||
|
||||
let _inputAttributes = {};
|
||||
$: {
|
||||
_inputAttributes = Object.assign({
|
||||
autocomplete: "off",
|
||||
autocorrect: "off",
|
||||
spellcheck: false
|
||||
}, inputAttributes);
|
||||
|
||||
if (!isSearchable) {
|
||||
_inputAttributes.readonly = true;
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
let _filteredItems;
|
||||
let _items = items;
|
||||
|
||||
if (items && items.length > 0 && typeof items[0] !== "object") {
|
||||
_items = items.map((item, index) => {
|
||||
return {
|
||||
index,
|
||||
value: item,
|
||||
label: item
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (loadOptions && filterText.length === 0 && originalItemsClone) {
|
||||
_filteredItems = JSON.parse(originalItemsClone);
|
||||
_items = JSON.parse(originalItemsClone);
|
||||
} else {
|
||||
_filteredItems = loadOptions
|
||||
? filterText.length === 0
|
||||
? []
|
||||
: _items
|
||||
: _items.filter(item => {
|
||||
let keepItem = true;
|
||||
|
||||
if (isMulti && selectedValue) {
|
||||
keepItem = !selectedValue.some(value => {
|
||||
return value[optionIdentifier] === item[optionIdentifier];
|
||||
});
|
||||
}
|
||||
|
||||
if (!keepItem) return false;
|
||||
if (filterText.length < 1) return true;
|
||||
return itemFilter(
|
||||
getOptionLabel(item, filterText),
|
||||
filterText,
|
||||
item
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (groupBy) {
|
||||
const groupValues = [];
|
||||
const groups = {};
|
||||
|
||||
_filteredItems.forEach(item => {
|
||||
const groupValue = groupBy(item);
|
||||
|
||||
if (!groupValues.includes(groupValue)) {
|
||||
groupValues.push(groupValue);
|
||||
groups[groupValue] = [];
|
||||
|
||||
if (groupValue) {
|
||||
groups[groupValue].push(
|
||||
Object.assign(createGroupHeaderItem(groupValue, item), {
|
||||
id: groupValue,
|
||||
isGroupHeader: true,
|
||||
isSelectable: isGroupHeaderSelectable
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
groups[groupValue].push(
|
||||
Object.assign({ isGroupItem: !!groupValue }, item)
|
||||
);
|
||||
});
|
||||
|
||||
const sortedGroupedItems = [];
|
||||
|
||||
groupFilter(groupValues).forEach(groupValue => {
|
||||
sortedGroupedItems.push(...groups[groupValue]);
|
||||
});
|
||||
|
||||
filteredItems = sortedGroupedItems;
|
||||
} else {
|
||||
filteredItems = _filteredItems;
|
||||
}
|
||||
}
|
||||
|
||||
beforeUpdate(() => {
|
||||
if (isMulti && selectedValue && selectedValue.length > 1) {
|
||||
checkSelectedValueForDuplicates();
|
||||
}
|
||||
|
||||
if (!isMulti && selectedValue && prev_selectedValue !== selectedValue) {
|
||||
if (
|
||||
!prev_selectedValue ||
|
||||
JSON.stringify(selectedValue[optionIdentifier]) !==
|
||||
JSON.stringify(prev_selectedValue[optionIdentifier])
|
||||
) {
|
||||
dispatch("select", selectedValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
isMulti &&
|
||||
JSON.stringify(selectedValue) !== JSON.stringify(prev_selectedValue)
|
||||
) {
|
||||
if (checkSelectedValueForDuplicates()) {
|
||||
dispatch("select", selectedValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (container && listOpen !== prev_listOpen) {
|
||||
if (listOpen) {
|
||||
loadList();
|
||||
} else {
|
||||
removeList();
|
||||
}
|
||||
}
|
||||
|
||||
if (filterText !== prev_filterText) {
|
||||
if (filterText.length > 0) {
|
||||
isFocused = true;
|
||||
listOpen = true;
|
||||
|
||||
if (loadOptions) {
|
||||
getItems();
|
||||
} else {
|
||||
loadList();
|
||||
listOpen = true;
|
||||
|
||||
if (isMulti) {
|
||||
activeSelectedValue = undefined;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setList([]);
|
||||
}
|
||||
|
||||
if (list) {
|
||||
list.$set({
|
||||
filterText
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (isFocused !== prev_isFocused) {
|
||||
if (isFocused || listOpen) {
|
||||
handleFocus();
|
||||
} else {
|
||||
resetFilter();
|
||||
if (input) input.blur();
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_filteredItems !== filteredItems) {
|
||||
let _filteredItems = [...filteredItems];
|
||||
|
||||
if (isCreatable && filterText) {
|
||||
const itemToCreate = createItem(filterText);
|
||||
itemToCreate.isCreator = true;
|
||||
|
||||
const existingItemWithFilterValue = _filteredItems.find(item => {
|
||||
return item[optionIdentifier] === itemToCreate[optionIdentifier];
|
||||
});
|
||||
|
||||
let existingSelectionWithFilterValue;
|
||||
|
||||
if (selectedValue) {
|
||||
if (isMulti) {
|
||||
existingSelectionWithFilterValue = selectedValue.find(selection => {
|
||||
return (
|
||||
selection[optionIdentifier] === itemToCreate[optionIdentifier]
|
||||
);
|
||||
});
|
||||
} else if (
|
||||
selectedValue[optionIdentifier] === itemToCreate[optionIdentifier]
|
||||
) {
|
||||
existingSelectionWithFilterValue = selectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!existingItemWithFilterValue && !existingSelectionWithFilterValue) {
|
||||
_filteredItems = [..._filteredItems, itemToCreate];
|
||||
}
|
||||
}
|
||||
|
||||
setList(_filteredItems);
|
||||
}
|
||||
|
||||
prev_selectedValue = selectedValue;
|
||||
prev_listOpen = listOpen;
|
||||
prev_filterText = filterText;
|
||||
prev_isFocused = isFocused;
|
||||
prev_filteredItems = filteredItems;
|
||||
});
|
||||
|
||||
function checkSelectedValueForDuplicates() {
|
||||
let noDuplicates = true;
|
||||
if (selectedValue) {
|
||||
const ids = [];
|
||||
const uniqueValues = [];
|
||||
|
||||
selectedValue.forEach(val => {
|
||||
if (!ids.includes(val[optionIdentifier])) {
|
||||
ids.push(val[optionIdentifier]);
|
||||
uniqueValues.push(val);
|
||||
} else {
|
||||
noDuplicates = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!noDuplicates)
|
||||
selectedValue = uniqueValues;
|
||||
}
|
||||
return noDuplicates;
|
||||
}
|
||||
|
||||
function findItem(selection) {
|
||||
let matchTo = selection ? selection[optionIdentifier] : selectedValue[optionIdentifier];
|
||||
return items.find(item => item[optionIdentifier] === matchTo);
|
||||
}
|
||||
|
||||
function updateSelectedValueDisplay(items) {
|
||||
if (!items || items.length === 0 || items.some(item => typeof item !== "object")) return;
|
||||
if (!selectedValue || (isMulti ? selectedValue.some(selection => !selection || !selection[optionIdentifier]) : !selectedValue[optionIdentifier])) return;
|
||||
|
||||
if (Array.isArray(selectedValue)) {
|
||||
selectedValue = selectedValue.map(selection => findItem(selection) || selection);
|
||||
} else {
|
||||
selectedValue = findItem() || selectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
async function setList(items) {
|
||||
await tick();
|
||||
if (!listOpen) return;
|
||||
if (list) return list.$set({ items });
|
||||
if (loadOptions && getItemsHasInvoked && items.length > 0) loadList();
|
||||
}
|
||||
|
||||
function handleMultiItemClear(event) {
|
||||
const { detail } = event;
|
||||
const itemToRemove =
|
||||
selectedValue[detail ? detail.i : selectedValue.length - 1];
|
||||
|
||||
if (selectedValue.length === 1) {
|
||||
selectedValue = undefined;
|
||||
} else {
|
||||
selectedValue = selectedValue.filter(item => {
|
||||
return item !== itemToRemove;
|
||||
});
|
||||
}
|
||||
|
||||
dispatch("clear", itemToRemove);
|
||||
|
||||
getPosition();
|
||||
}
|
||||
|
||||
async function getPosition() {
|
||||
await tick();
|
||||
if (!target || !container) return;
|
||||
const { top, height, width } = container.getBoundingClientRect();
|
||||
|
||||
target.style["min-width"] = `${width}px`;
|
||||
target.style.width = `${listAutoWidth ? "auto" : "100%"}`;
|
||||
target.style.left = "0";
|
||||
|
||||
if (listPlacement === "top") {
|
||||
target.style.bottom = `${height + 5}px`;
|
||||
} else {
|
||||
target.style.top = `${height + 5}px`;
|
||||
}
|
||||
|
||||
target = target;
|
||||
|
||||
if (listPlacement === "auto" && isOutOfViewport(target).bottom) {
|
||||
target.style.top = ``;
|
||||
target.style.bottom = `${height + 5}px`;
|
||||
}
|
||||
|
||||
target.style.visibility = "";
|
||||
}
|
||||
|
||||
function handleKeyDown(e) {
|
||||
if (!isFocused) return;
|
||||
|
||||
switch (e.key) {
|
||||
case "ArrowDown":
|
||||
e.preventDefault();
|
||||
listOpen = true;
|
||||
activeSelectedValue = undefined;
|
||||
break;
|
||||
case "ArrowUp":
|
||||
e.preventDefault();
|
||||
listOpen = true;
|
||||
activeSelectedValue = undefined;
|
||||
break;
|
||||
case "Tab":
|
||||
if (!listOpen) isFocused = false;
|
||||
break;
|
||||
case "Backspace":
|
||||
if (!isMulti || filterText.length > 0) return;
|
||||
if (isMulti && selectedValue && selectedValue.length > 0) {
|
||||
handleMultiItemClear(
|
||||
activeSelectedValue !== undefined
|
||||
? activeSelectedValue
|
||||
: selectedValue.length - 1
|
||||
);
|
||||
if (activeSelectedValue === 0 || activeSelectedValue === undefined)
|
||||
break;
|
||||
activeSelectedValue =
|
||||
selectedValue.length > activeSelectedValue
|
||||
? activeSelectedValue - 1
|
||||
: undefined;
|
||||
}
|
||||
break;
|
||||
case "ArrowLeft":
|
||||
if (list) list.$set({ hoverItemIndex: -1 });
|
||||
if (!isMulti || filterText.length > 0) return;
|
||||
|
||||
if (activeSelectedValue === undefined) {
|
||||
activeSelectedValue = selectedValue.length - 1;
|
||||
} else if (
|
||||
selectedValue.length > activeSelectedValue &&
|
||||
activeSelectedValue !== 0
|
||||
) {
|
||||
activeSelectedValue -= 1;
|
||||
}
|
||||
break;
|
||||
case "ArrowRight":
|
||||
if (list) list.$set({ hoverItemIndex: -1 });
|
||||
if (
|
||||
!isMulti ||
|
||||
filterText.length > 0 ||
|
||||
activeSelectedValue === undefined
|
||||
)
|
||||
return;
|
||||
if (activeSelectedValue === selectedValue.length - 1) {
|
||||
activeSelectedValue = undefined;
|
||||
} else if (activeSelectedValue < selectedValue.length - 1) {
|
||||
activeSelectedValue += 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function handleFocus() {
|
||||
isFocused = true;
|
||||
if (input) input.focus();
|
||||
}
|
||||
|
||||
function removeList() {
|
||||
resetFilter();
|
||||
activeSelectedValue = undefined;
|
||||
|
||||
if (!list) return;
|
||||
list.$destroy();
|
||||
list = undefined;
|
||||
|
||||
if (!target) return;
|
||||
if (target.parentNode) target.parentNode.removeChild(target);
|
||||
target = undefined;
|
||||
|
||||
list = list;
|
||||
target = target;
|
||||
}
|
||||
|
||||
function handleWindowClick(event) {
|
||||
if (!container) return;
|
||||
const eventTarget =
|
||||
event.path && event.path.length > 0 ? event.path[0] : event.target;
|
||||
if (container.contains(eventTarget)) return;
|
||||
isFocused = false;
|
||||
listOpen = false;
|
||||
activeSelectedValue = undefined;
|
||||
if (input) input.blur();
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
if (isDisabled) return;
|
||||
isFocused = true;
|
||||
listOpen = !listOpen;
|
||||
}
|
||||
|
||||
export function handleClear() {
|
||||
selectedValue = undefined;
|
||||
listOpen = false;
|
||||
dispatch("clear", selectedValue);
|
||||
handleFocus();
|
||||
}
|
||||
|
||||
async function loadList() {
|
||||
await tick();
|
||||
if (target && list) return;
|
||||
|
||||
const data = {
|
||||
Item,
|
||||
filterText,
|
||||
optionIdentifier,
|
||||
noOptionsMessage,
|
||||
hideEmptyState,
|
||||
isVirtualList,
|
||||
selectedValue,
|
||||
isMulti,
|
||||
getGroupHeaderLabel,
|
||||
items: filteredItems,
|
||||
itemHeight
|
||||
};
|
||||
|
||||
if (getOptionLabel) {
|
||||
data.getOptionLabel = getOptionLabel;
|
||||
}
|
||||
|
||||
target = document.createElement("div");
|
||||
|
||||
Object.assign(target.style, {
|
||||
position: "absolute",
|
||||
"z-index": 2,
|
||||
visibility: "hidden"
|
||||
});
|
||||
|
||||
list = list;
|
||||
target = target;
|
||||
if (container) container.appendChild(target);
|
||||
|
||||
list = new List({
|
||||
target,
|
||||
props: data
|
||||
});
|
||||
|
||||
list.$on("itemSelected", event => {
|
||||
const { detail } = event;
|
||||
|
||||
if (detail) {
|
||||
const item = Object.assign({}, detail);
|
||||
|
||||
if (!item.isGroupHeader || item.isSelectable) {
|
||||
|
||||
if (isMulti) {
|
||||
selectedValue = selectedValue ? selectedValue.concat([item]) : [item];
|
||||
} else {
|
||||
selectedValue = item;
|
||||
}
|
||||
|
||||
resetFilter();
|
||||
selectedValue = selectedValue;
|
||||
|
||||
setTimeout(() => {
|
||||
listOpen = false;
|
||||
activeSelectedValue = undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
list.$on("itemCreated", event => {
|
||||
const { detail } = event;
|
||||
if (isMulti) {
|
||||
selectedValue = selectedValue || [];
|
||||
selectedValue = [...selectedValue, createItem(detail)];
|
||||
} else {
|
||||
selectedValue = createItem(detail);
|
||||
}
|
||||
|
||||
dispatch('itemCreated', detail);
|
||||
filterText = "";
|
||||
listOpen = false;
|
||||
activeSelectedValue = undefined;
|
||||
resetFilter();
|
||||
});
|
||||
|
||||
list.$on("closeList", () => {
|
||||
listOpen = false;
|
||||
});
|
||||
|
||||
(list = list), (target = target);
|
||||
getPosition();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (isFocused) input.focus();
|
||||
if (listOpen) loadList();
|
||||
|
||||
if (items && items.length > 0) {
|
||||
originalItemsClone = JSON.stringify(items);
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
removeList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.selectContainer {
|
||||
--padding: 0 16px;
|
||||
|
||||
border: var(--border, 1px solid #d8dbdf);
|
||||
border-radius: var(--borderRadius, 3px);
|
||||
height: var(--height, 42px);
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: var(--padding);
|
||||
background: var(--background, #fff);
|
||||
}
|
||||
|
||||
.selectContainer input {
|
||||
cursor: default;
|
||||
border: none;
|
||||
color: var(--inputColor, #3f4f5f);
|
||||
height: var(--height, 42px);
|
||||
line-height: var(--height, 42px);
|
||||
padding: var(--inputPadding, var(--padding));
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
font-size: var(--inputFontSize, 14px);
|
||||
letter-spacing: var(--inputLetterSpacing, -0.08px);
|
||||
position: absolute;
|
||||
left: var(--inputLeft, 0);
|
||||
}
|
||||
|
||||
.selectContainer input::placeholder {
|
||||
color: var(--placeholderColor, #78848f);
|
||||
opacity: var(--placeholderOpacity, 1);
|
||||
}
|
||||
|
||||
.selectContainer input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.selectContainer:hover {
|
||||
border-color: var(--borderHoverColor, #b2b8bf);
|
||||
}
|
||||
|
||||
.selectContainer.focused {
|
||||
border-color: var(--borderFocusColor, #006fe8);
|
||||
}
|
||||
|
||||
.selectContainer.disabled {
|
||||
background: var(--disabledBackground, #ebedef);
|
||||
border-color: var(--disabledBorderColor, #ebedef);
|
||||
color: var(--disabledColor, #c1c6cc);
|
||||
}
|
||||
|
||||
.selectContainer.disabled input::placeholder {
|
||||
color: var(--disabledPlaceholderColor, #c1c6cc);
|
||||
opacity: var(--disabledPlaceholderOpacity, 1);
|
||||
}
|
||||
|
||||
.selectedItem {
|
||||
line-height: var(--height, 42px);
|
||||
height: var(--height, 42px);
|
||||
overflow-x: hidden;
|
||||
padding: var(--selectedItemPadding, 0 20px 0 0);
|
||||
}
|
||||
|
||||
.selectedItem:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.clearSelect {
|
||||
position: absolute;
|
||||
right: var(--clearSelectRight, 10px);
|
||||
top: var(--clearSelectTop, 11px);
|
||||
bottom: var(--clearSelectBottom, 11px);
|
||||
width: var(--clearSelectWidth, 20px);
|
||||
color: var(--clearSelectColor, #c5cacf);
|
||||
flex: none !important;
|
||||
}
|
||||
|
||||
.clearSelect:hover {
|
||||
color: var(--clearSelectHoverColor, #2c3e50);
|
||||
}
|
||||
|
||||
.selectContainer.focused .clearSelect {
|
||||
color: var(--clearSelectFocusColor, #3f4f5f);
|
||||
}
|
||||
|
||||
.indicator {
|
||||
position: absolute;
|
||||
right: var(--indicatorRight, 10px);
|
||||
top: var(--indicatorTop, 11px);
|
||||
width: var(--indicatorWidth, 20px);
|
||||
height: var(--indicatorHeight, 20px);
|
||||
color: var(--indicatorColor, #c5cacf);
|
||||
}
|
||||
|
||||
.indicator svg {
|
||||
display: inline-block;
|
||||
fill: var(--indicatorFill, currentcolor);
|
||||
line-height: 1;
|
||||
stroke: var(--indicatorStroke, currentcolor);
|
||||
stroke-width: 0;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
position: absolute;
|
||||
right: var(--spinnerRight, 10px);
|
||||
top: var(--spinnerLeft, 11px);
|
||||
width: var(--spinnerWidth, 20px);
|
||||
height: var(--spinnerHeight, 20px);
|
||||
color: var(--spinnerColor, #51ce6c);
|
||||
animation: rotate 0.75s linear infinite;
|
||||
}
|
||||
|
||||
.spinner_icon {
|
||||
display: block;
|
||||
height: 100%;
|
||||
transform-origin: center center;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: auto;
|
||||
-webkit-transform: none;
|
||||
}
|
||||
|
||||
.spinner_path {
|
||||
stroke-dasharray: 90;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
|
||||
.multiSelect {
|
||||
display: flex;
|
||||
padding: var(--multiSelectPadding, 0 35px 0 16px);
|
||||
height: auto;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.multiSelect > * {
|
||||
flex: 1 1 50px;
|
||||
}
|
||||
|
||||
.selectContainer.multiSelect input {
|
||||
padding: var(--multiSelectInputPadding, 0);
|
||||
position: relative;
|
||||
margin: var(--multiSelectInputMargin, 0);
|
||||
}
|
||||
|
||||
.hasError {
|
||||
border: var(--errorBorder, 1px solid #ff2d55);
|
||||
background: var(--errorBackground, #fff);
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:window
|
||||
on:click={handleWindowClick}
|
||||
on:keydown={handleKeyDown}
|
||||
on:resize={getPosition} />
|
||||
|
||||
<div
|
||||
class="selectContainer {containerClasses}"
|
||||
class:hasError
|
||||
class:multiSelect={isMulti}
|
||||
class:disabled={isDisabled}
|
||||
class:focused={isFocused}
|
||||
style={containerStyles}
|
||||
on:click={handleClick}
|
||||
bind:this={container}>
|
||||
|
||||
{#if Icon}
|
||||
<svelte:component this={Icon} {...iconProps} />
|
||||
{/if}
|
||||
|
||||
{#if isMulti && selectedValue && selectedValue.length > 0}
|
||||
<svelte:component
|
||||
this={MultiSelection}
|
||||
{selectedValue}
|
||||
{getSelectionLabel}
|
||||
{activeSelectedValue}
|
||||
{isDisabled}
|
||||
{multiFullItemClearable}
|
||||
on:multiItemClear={handleMultiItemClear}
|
||||
on:focus={handleFocus} />
|
||||
{/if}
|
||||
|
||||
{#if isDisabled}
|
||||
<input
|
||||
{..._inputAttributes}
|
||||
bind:this={input}
|
||||
on:focus={handleFocus}
|
||||
bind:value={filterText}
|
||||
placeholder={placeholderText}
|
||||
style={inputStyles}
|
||||
disabled />
|
||||
{:else}
|
||||
<input
|
||||
{..._inputAttributes}
|
||||
bind:this={input}
|
||||
on:focus={handleFocus}
|
||||
bind:value={filterText}
|
||||
placeholder={placeholderText}
|
||||
style={inputStyles} />
|
||||
{/if}
|
||||
|
||||
{#if !isMulti && showSelectedItem}
|
||||
<div class="selectedItem" on:focus={handleFocus}>
|
||||
<svelte:component
|
||||
this={Selection}
|
||||
item={selectedValue}
|
||||
{getSelectionLabel} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if showSelectedItem && isClearable && !isDisabled && !isWaiting}
|
||||
<div class="clearSelect" on:click|preventDefault={handleClear}>
|
||||
<svelte:component this={ClearIcon} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if showIndicator || (showChevron && !selectedValue || (!isSearchable && !isDisabled && !isWaiting && ((showSelectedItem && !isClearable) || !showSelectedItem)))}
|
||||
<div class="indicator">
|
||||
{#if indicatorSvg}
|
||||
{@html indicatorSvg}
|
||||
{:else}
|
||||
<svg
|
||||
width="100%"
|
||||
height="100%"
|
||||
viewBox="0 0 20 20"
|
||||
focusable="false">
|
||||
<path
|
||||
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747
|
||||
3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0
|
||||
1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502
|
||||
0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0
|
||||
0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" />
|
||||
</svg>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if isWaiting}
|
||||
<div class="spinner">
|
||||
<svg class="spinner_icon" viewBox="25 25 50 50">
|
||||
<circle
|
||||
class="spinner_path"
|
||||
cx="50"
|
||||
cy="50"
|
||||
r="20"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="5"
|
||||
stroke-miterlimit="10" />
|
||||
</svg>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
/*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
||||
module.exports = runParallel
|
||||
|
||||
const queueMicrotask = require('queue-microtask')
|
||||
|
||||
function runParallel (tasks, cb) {
|
||||
let results, pending, keys
|
||||
let isSync = true
|
||||
|
||||
if (Array.isArray(tasks)) {
|
||||
results = []
|
||||
pending = tasks.length
|
||||
} else {
|
||||
keys = Object.keys(tasks)
|
||||
results = {}
|
||||
pending = keys.length
|
||||
}
|
||||
|
||||
function done (err) {
|
||||
function end () {
|
||||
if (cb) cb(err, results)
|
||||
cb = null
|
||||
}
|
||||
if (isSync) queueMicrotask(end)
|
||||
else end()
|
||||
}
|
||||
|
||||
function each (i, err, result) {
|
||||
results[i] = result
|
||||
if (--pending === 0 || err) {
|
||||
done(err)
|
||||
}
|
||||
}
|
||||
|
||||
if (!pending) {
|
||||
// empty
|
||||
done(null)
|
||||
} else if (keys) {
|
||||
// object
|
||||
keys.forEach(function (key) {
|
||||
tasks[key](function (err, result) { each(key, err, result) })
|
||||
})
|
||||
} else {
|
||||
// array
|
||||
tasks.forEach(function (task, i) {
|
||||
task(function (err, result) { each(i, err, result) })
|
||||
})
|
||||
}
|
||||
|
||||
isSync = false
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
export declare const FormData: {
|
||||
new (): FormData;
|
||||
prototype: FormData;
|
||||
};
|
||||
export declare function formDataToBlob(formData: FormData): Blob;
|
||||
@@ -0,0 +1,33 @@
|
||||
let Declaration = require('../declaration')
|
||||
|
||||
class OverscrollBehavior extends Declaration {
|
||||
/**
|
||||
* Change property name for IE
|
||||
*/
|
||||
prefixed(prop, prefix) {
|
||||
return prefix + 'scroll-chaining'
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property name by spec
|
||||
*/
|
||||
normalize() {
|
||||
return 'overscroll-behavior'
|
||||
}
|
||||
|
||||
/**
|
||||
* Change value for IE
|
||||
*/
|
||||
set(decl, prefix) {
|
||||
if (decl.value === 'auto') {
|
||||
decl.value = 'chained'
|
||||
} else if (decl.value === 'none' || decl.value === 'contain') {
|
||||
decl.value = 'none'
|
||||
}
|
||||
return super.set(decl, prefix)
|
||||
}
|
||||
}
|
||||
|
||||
OverscrollBehavior.names = ['overscroll-behavior', 'scroll-chaining']
|
||||
|
||||
module.exports = OverscrollBehavior
|
||||
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var SameValueNonNumeric = require('./SameValueNonNumeric');
|
||||
var Type = require('./Type');
|
||||
var BigIntEqual = require('./BigInt/equal');
|
||||
var NumberEqual = require('./Number/equal');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-isstrictlyequal
|
||||
|
||||
module.exports = function IsStrictlyEqual(x, y) {
|
||||
var xType = Type(x);
|
||||
var yType = Type(y);
|
||||
if (xType !== yType) {
|
||||
return false;
|
||||
}
|
||||
if (xType === 'Number' || xType === 'BigInt') {
|
||||
return xType === 'Number' ? NumberEqual(x, y) : BigIntEqual(x, y);
|
||||
}
|
||||
return SameValueNonNumeric(x, y);
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")() ? Number.isFinite : require("./shim");
|
||||
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var getTime = Date.prototype.getTime;
|
||||
|
||||
module.exports = function () { return new Date(getTime.call(this)); };
|
||||
@@ -0,0 +1,6 @@
|
||||
import assertString from './util/assertString';
|
||||
var eth = /^(0x)[0-9a-f]{40}$/i;
|
||||
export default function isEthereumAddress(str) {
|
||||
assertString(str);
|
||||
return eth.test(str);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
var castPath = require('./_castPath'),
|
||||
last = require('./last'),
|
||||
parent = require('./_parent'),
|
||||
toKey = require('./_toKey');
|
||||
|
||||
/**
|
||||
* The base implementation of `_.unset`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {Array|string} path The property path to unset.
|
||||
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
|
||||
*/
|
||||
function baseUnset(object, path) {
|
||||
path = castPath(path, object);
|
||||
object = parent(object, path);
|
||||
return object == null || delete object[toKey(last(path))];
|
||||
}
|
||||
|
||||
module.exports = baseUnset;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O"},C:{"1":"6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 3 4 5 DC tB I v J D E F A B C K L G M N O w g x y z EC FC"},D:{"1":"BB CB DB EB FB GB HB IB JB KB LB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB","260":"MB"},E:{"1":"B C K L G 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D HC zB IC JC","132":"E F A KC LC"},F:{"1":"0 1 2 3 4 5 6 7 8 y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"F B C G M N O w g x PC QC RC SC qB AC TC rB","260":"9"},G:{"1":"cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"zB UC BC VC WC XC","132":"E YC ZC aC bC"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:4,C:"CSS background-blend-mode"};
|
||||
@@ -0,0 +1,45 @@
|
||||
let nextHandle = 1;
|
||||
// The promise needs to be created lazily otherwise it won't be patched by Zones
|
||||
let resolved: Promise<any>;
|
||||
const activeHandles: { [key: number]: any } = {};
|
||||
|
||||
/**
|
||||
* Finds the handle in the list of active handles, and removes it.
|
||||
* Returns `true` if found, `false` otherwise. Used both to clear
|
||||
* Immediate scheduled tasks, and to identify if a task should be scheduled.
|
||||
*/
|
||||
function findAndClearHandle(handle: number): boolean {
|
||||
if (handle in activeHandles) {
|
||||
delete activeHandles[handle];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions to schedule and unschedule microtasks.
|
||||
*/
|
||||
export const Immediate = {
|
||||
setImmediate(cb: () => void): number {
|
||||
const handle = nextHandle++;
|
||||
activeHandles[handle] = true;
|
||||
if (!resolved) {
|
||||
resolved = Promise.resolve();
|
||||
}
|
||||
resolved.then(() => findAndClearHandle(handle) && cb());
|
||||
return handle;
|
||||
},
|
||||
|
||||
clearImmediate(handle: number): void {
|
||||
findAndClearHandle(handle);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Used for internal testing purposes only. Do not export from library.
|
||||
*/
|
||||
export const TestTools = {
|
||||
pending() {
|
||||
return Object.keys(activeHandles).length;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
import { endpoint } from "@octokit/endpoint";
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { VERSION } from "./version";
|
||||
import withDefaults from "./with-defaults";
|
||||
export const request = withDefaults(endpoint, {
|
||||
headers: {
|
||||
"user-agent": `octokit-request.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"zip.js","sourceRoot":"","sources":["../../../../src/internal/observable/zip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA4CjD,MAAM,UAAU,GAAG;IAAC,cAAkB;SAAlB,UAAkB,EAAlB,qBAAkB,EAAlB,IAAkB;QAAlB,yBAAkB;;IACpC,IAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE/C,IAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAA0B,CAAC;IAE9D,OAAO,OAAO,CAAC,MAAM;QACnB,CAAC,CAAC,IAAI,UAAU,CAAY,UAAC,UAAU;YAGnC,IAAI,OAAO,GAAgB,OAAO,CAAC,GAAG,CAAC,cAAM,OAAA,EAAE,EAAF,CAAE,CAAC,CAAC;YAKjD,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,CAAC;YAGzC,UAAU,CAAC,GAAG,CAAC;gBACb,OAAO,GAAG,SAAS,GAAG,IAAK,CAAC;YAC9B,CAAC,CAAC,CAAC;oCAKM,WAAW;gBAClB,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CACvC,wBAAwB,CACtB,UAAU,EACV,UAAC,KAAK;oBACJ,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAIjC,IAAI,OAAO,CAAC,KAAK,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,MAAM,EAAb,CAAa,CAAC,EAAE;wBAC5C,IAAM,MAAM,GAAQ,OAAO,CAAC,GAAG,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,KAAK,EAAG,EAAf,CAAe,CAAC,CAAC;wBAE7D,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,wCAAI,MAAM,IAAE,CAAC,CAAC,MAAM,CAAC,CAAC;wBAIrE,IAAI,OAAO,CAAC,IAAI,CAAC,UAAC,MAAM,EAAE,CAAC,IAAK,OAAA,CAAC,MAAM,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,EAA9B,CAA8B,CAAC,EAAE;4BAC/D,UAAU,CAAC,QAAQ,EAAE,CAAC;yBACvB;qBACF;gBACH,CAAC,EACD;oBAGE,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;oBAI9B,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACxD,CAAC,CACF,CACF,CAAC;;YA/BJ,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,IAAI,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE;wBAAlF,WAAW;aAgCnB;YAGD,OAAO;gBACL,OAAO,GAAG,SAAS,GAAG,IAAK,CAAC;YAC9B,CAAC,CAAC;QACJ,CAAC,CAAC;QACJ,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC"}
|
||||
@@ -0,0 +1,27 @@
|
||||
# Time value
|
||||
|
||||
_number_ primitive which is a valid _time value_ (as used internally in _Date_ instances)
|
||||
|
||||
## `time-value/coerce`
|
||||
|
||||
Follows [`integer/coerce`](integer.md#integercoerce) but returns `null` in place of values which go beyond 100 000 0000 days from unix epoch
|
||||
|
||||
```javascript
|
||||
const coerceToTimeValue = require("type/time-value/coerce");
|
||||
|
||||
coerceToTimeValue(12312312); // true
|
||||
coerceToTimeValue(Number.MAX_SAFE_INTEGER); // false
|
||||
coerceToTimeValue("foo"); // false
|
||||
```
|
||||
|
||||
## `time-value/ensure`
|
||||
|
||||
If given argument is a _time value_ coercible value (via [`time-value/coerce`](#time-valuecoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureTimeValue = require("type/time-value/ensure");
|
||||
|
||||
ensureTimeValue(12.93); // "12"
|
||||
ensureTimeValue(Number.MAX_SAFE_INTEGER); // Thrown TypeError: null is not a natural number
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "4.2.0";
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sample.js","sourceRoot":"","sources":["../../../../src/internal/operators/sample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AA0ChE,MAAM,UAAU,MAAM,CAAI,QAA8B;IACtD,OAAO,OAAO,CAAC,UAAC,MAAM,EAAE,UAAU;QAChC,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,SAAS,GAAa,IAAI,CAAC;QAC/B,MAAM,CAAC,SAAS,CACd,wBAAwB,CAAC,UAAU,EAAE,UAAC,KAAK;YACzC,QAAQ,GAAG,IAAI,CAAC;YAChB,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC,CACH,CAAC;QACF,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,CAC3B,wBAAwB,CACtB,UAAU,EACV;YACE,IAAI,QAAQ,EAAE;gBACZ,QAAQ,GAAG,KAAK,CAAC;gBACjB,IAAM,KAAK,GAAG,SAAU,CAAC;gBACzB,SAAS,GAAG,IAAI,CAAC;gBACjB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACxB;QACH,CAAC,EACD,IAAI,CACL,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.takeLast = void 0;
|
||||
var empty_1 = require("../observable/empty");
|
||||
var lift_1 = require("../util/lift");
|
||||
var OperatorSubscriber_1 = require("./OperatorSubscriber");
|
||||
function takeLast(count) {
|
||||
return count <= 0
|
||||
? function () { return empty_1.EMPTY; }
|
||||
: lift_1.operate(function (source, subscriber) {
|
||||
var buffer = [];
|
||||
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
|
||||
buffer.push(value);
|
||||
count < buffer.length && buffer.shift();
|
||||
}, function () {
|
||||
var e_1, _a;
|
||||
try {
|
||||
for (var buffer_1 = __values(buffer), buffer_1_1 = buffer_1.next(); !buffer_1_1.done; buffer_1_1 = buffer_1.next()) {
|
||||
var value = buffer_1_1.value;
|
||||
subscriber.next(value);
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (buffer_1_1 && !buffer_1_1.done && (_a = buffer_1.return)) _a.call(buffer_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
subscriber.complete();
|
||||
}, undefined, function () {
|
||||
buffer = null;
|
||||
}));
|
||||
});
|
||||
}
|
||||
exports.takeLast = takeLast;
|
||||
//# sourceMappingURL=takeLast.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"animationFrameProvider.js","sourceRoot":"","sources":["../../../../src/internal/scheduler/animationFrameProvider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAc/C,MAAM,CAAC,IAAM,sBAAsB,GAA2B;IAG5D,QAAQ,EAAR,UAAS,QAAQ;QACf,IAAI,OAAO,GAAG,qBAAqB,CAAC;QACpC,IAAI,MAAM,GAA4C,oBAAoB,CAAC;QACnE,IAAA,QAAQ,GAAK,sBAAsB,SAA3B,CAA4B;QAC5C,IAAI,QAAQ,EAAE;YACZ,OAAO,GAAG,QAAQ,CAAC,qBAAqB,CAAC;YACzC,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC;SACxC;QACD,IAAM,MAAM,GAAG,OAAO,CAAC,UAAC,SAAS;YAI/B,MAAM,GAAG,SAAS,CAAC;YACnB,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,YAAY,CAAC,cAAM,OAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,MAAM,CAAC,EAAhB,CAAgB,CAAC,CAAC;IAClD,CAAC;IACD,qBAAqB;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QACnB,IAAA,QAAQ,GAAK,sBAAsB,SAA3B,CAA4B;QAC5C,OAAO,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,qBAAqB,KAAI,qBAAqB,CAAC,wCAAI,IAAI,IAAE;IAC7E,CAAC;IACD,oBAAoB;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAClB,IAAA,QAAQ,GAAK,sBAAsB,SAA3B,CAA4B;QAC5C,OAAO,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,oBAAoB,KAAI,oBAAoB,CAAC,wCAAI,IAAI,IAAE;IAC3E,CAAC;IACD,QAAQ,EAAE,SAAS;CACpB,CAAC"}
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('propertyOf', require('../get'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,90 @@
|
||||
import { __extends } from "tslib";
|
||||
import { Action } from './Action';
|
||||
import { intervalProvider } from './intervalProvider';
|
||||
import { arrRemove } from '../util/arrRemove';
|
||||
var AsyncAction = (function (_super) {
|
||||
__extends(AsyncAction, _super);
|
||||
function AsyncAction(scheduler, work) {
|
||||
var _this = _super.call(this, scheduler, work) || this;
|
||||
_this.scheduler = scheduler;
|
||||
_this.work = work;
|
||||
_this.pending = false;
|
||||
return _this;
|
||||
}
|
||||
AsyncAction.prototype.schedule = function (state, delay) {
|
||||
var _a;
|
||||
if (delay === void 0) { delay = 0; }
|
||||
if (this.closed) {
|
||||
return this;
|
||||
}
|
||||
this.state = state;
|
||||
var id = this.id;
|
||||
var scheduler = this.scheduler;
|
||||
if (id != null) {
|
||||
this.id = this.recycleAsyncId(scheduler, id, delay);
|
||||
}
|
||||
this.pending = true;
|
||||
this.delay = delay;
|
||||
this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay);
|
||||
return this;
|
||||
};
|
||||
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
|
||||
if (delay === void 0) { delay = 0; }
|
||||
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
||||
};
|
||||
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) {
|
||||
if (delay === void 0) { delay = 0; }
|
||||
if (delay != null && this.delay === delay && this.pending === false) {
|
||||
return id;
|
||||
}
|
||||
if (id != null) {
|
||||
intervalProvider.clearInterval(id);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
AsyncAction.prototype.execute = function (state, delay) {
|
||||
if (this.closed) {
|
||||
return new Error('executing a cancelled action');
|
||||
}
|
||||
this.pending = false;
|
||||
var error = this._execute(state, delay);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
else if (this.pending === false && this.id != null) {
|
||||
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
||||
}
|
||||
};
|
||||
AsyncAction.prototype._execute = function (state, _delay) {
|
||||
var errored = false;
|
||||
var errorValue;
|
||||
try {
|
||||
this.work(state);
|
||||
}
|
||||
catch (e) {
|
||||
errored = true;
|
||||
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
||||
}
|
||||
if (errored) {
|
||||
this.unsubscribe();
|
||||
return errorValue;
|
||||
}
|
||||
};
|
||||
AsyncAction.prototype.unsubscribe = function () {
|
||||
if (!this.closed) {
|
||||
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
||||
var actions = scheduler.actions;
|
||||
this.work = this.state = this.scheduler = null;
|
||||
this.pending = false;
|
||||
arrRemove(actions, this);
|
||||
if (id != null) {
|
||||
this.id = this.recycleAsyncId(scheduler, id, null);
|
||||
}
|
||||
this.delay = null;
|
||||
_super.prototype.unsubscribe.call(this);
|
||||
}
|
||||
};
|
||||
return AsyncAction;
|
||||
}(Action));
|
||||
export { AsyncAction };
|
||||
//# sourceMappingURL=AsyncAction.js.map
|
||||
@@ -0,0 +1,28 @@
|
||||
var Marker = require('../../../tokenizer/marker');
|
||||
|
||||
function everyValuesPair(fn, left, right) {
|
||||
var leftSize = left.value.length;
|
||||
var rightSize = right.value.length;
|
||||
var total = Math.max(leftSize, rightSize);
|
||||
var lowerBound = Math.min(leftSize, rightSize) - 1;
|
||||
var leftValue;
|
||||
var rightValue;
|
||||
var position;
|
||||
|
||||
for (position = 0; position < total; position++) {
|
||||
leftValue = left.value[position] && left.value[position][1] || leftValue;
|
||||
rightValue = right.value[position] && right.value[position][1] || rightValue;
|
||||
|
||||
if (leftValue == Marker.COMMA || rightValue == Marker.COMMA) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fn(leftValue, rightValue, position, position <= lowerBound)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = everyValuesPair;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O P Q R S"},C:{"1":"bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB EC FC"},D:{"1":"T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S"},E:{"1":"G MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D E F A B C K L HC zB IC JC KC LC 0B qB rB 1B"},F:{"1":"iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB PC QC RC SC qB AC TC rB"},G:{"1":"mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"E zB UC BC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"2":"vC"},P:{"1":"g 4C 5C sB 6C 7C 8C","2":"I wC xC yC zC 0C 0B 1C 2C 3C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"BD","2":"AD"}},B:5,C:"gap property for Flexbox"};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0.00246,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0.00246,"44":0,"45":0,"46":0,"47":0,"48":0.00246,"49":0,"50":0.00246,"51":0,"52":0.00246,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0.00246,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0.00246,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00246,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0.00246,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0.00246,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.00246,"101":0,"102":0.00985,"103":0.00246,"104":0.00739,"105":0.00739,"106":0.00492,"107":0.00985,"108":0.00985,"109":0.33237,"110":0.22897,"111":0.01723,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0.00246,"48":0,"49":0.00246,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0.00246,"57":0,"58":0.00246,"59":0,"60":0,"61":0,"62":0,"63":0.00246,"64":0.00246,"65":0.00246,"66":0,"67":0,"68":0,"69":0.00246,"70":0.00492,"71":0,"72":0.00492,"73":0,"74":0.00492,"75":0,"76":0,"77":0.00246,"78":0.00246,"79":0.00492,"80":0.00246,"81":0.00492,"83":0.00246,"84":0.00246,"85":0,"86":0.00246,"87":0.00492,"88":0.00246,"89":0,"90":0,"91":0.00492,"92":0.00985,"93":0.00492,"94":0.00492,"95":0.01231,"96":0.00492,"97":0.00246,"98":0.00246,"99":0.00246,"100":0.00492,"101":0.00492,"102":0.00985,"103":0.02708,"104":0.00739,"105":0.00985,"106":0.01231,"107":0.03447,"108":0.07386,"109":1.55598,"110":0.97003,"111":0.00246,"112":0,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0.00246,"25":0,"26":0,"27":0.00246,"28":0.00246,"29":0,"30":0.00246,"31":0.00246,"32":0,"33":0.00985,"34":0,"35":0,"36":0,"37":0.01477,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0.00246,"46":0.00246,"47":0.00492,"48":0,"49":0,"50":0,"51":0.00246,"52":0,"53":0,"54":0,"55":0,"56":0.00246,"57":0.03693,"58":0.01477,"60":0.0517,"62":0,"63":0.11325,"64":0.08371,"65":0.03693,"66":0.19942,"67":0.30036,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0.00739,"74":0.02216,"75":0,"76":0,"77":0,"78":0,"79":0.00246,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0.00246,"93":0,"94":0.05909,"95":0.09602,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0.01231},B:{"12":0.00492,"13":0.00246,"14":0.00246,"15":0.00246,"16":0.00246,"17":0,"18":0.00985,"79":0,"80":0,"81":0,"83":0,"84":0.00246,"85":0,"86":0,"87":0,"88":0,"89":0.00246,"90":0.00246,"91":0,"92":0.00492,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0.00246,"106":0.00246,"107":0.01477,"108":0.01231,"109":0.17726,"110":0.20435},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.00246,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0.00492,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0.00246,"12.1":0,"13.1":0.00985,"14.1":0.00492,"15.1":0,"15.2-15.3":0.00246,"15.4":0,"15.5":0.00246,"15.6":0.05663,"16.0":0.00246,"16.1":0.00985,"16.2":0.00739,"16.3":0.00985,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00175,"5.0-5.1":0.00291,"6.0-6.1":0.00058,"7.0-7.1":0.00524,"8.1-8.4":0,"9.0-9.2":0,"9.3":0.02564,"10.0-10.2":0.00175,"10.3":0.03263,"11.0-11.2":0.00117,"11.3-11.4":0.00524,"12.0-12.1":0.01515,"12.2-12.5":0.58093,"13.0-13.1":0.01224,"13.2":0.00466,"13.3":0.02855,"13.4-13.7":0.05069,"14.0-14.4":0.23598,"14.5-14.8":0.31465,"15.0-15.1":0.18413,"15.2-15.3":0.27561,"15.4":0.20219,"15.5":0.24472,"15.6":0.38515,"16.0":0.45391,"16.1":0.70154,"16.2":0.7872,"16.3":0.70038,"16.4":0.00291},P:{"4":0.09363,"20":0.11444,"5.0-5.4":0.0104,"6.2-6.4":0,"7.2-7.4":0.11444,"8.2":0,"9.2":0.07283,"10.1":0,"11.1-11.2":0.03121,"12.0":0.04161,"13.0":0.02081,"14.0":0.05202,"15.0":0.04161,"16.0":0.06242,"17.0":0.03121,"18.0":0.07283,"19.0":0.49938},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00261,"4.2-4.3":0.00174,"4.4":0,"4.4.3-4.4.4":0.08258},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00985,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0.45982,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.64827},H:{"0":17.57004},L:{"0":63.73447},R:{_:"0"},M:{"0":0.20353},Q:{"13.1":0}};
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
var iteratorSymbol = require("es6-symbol").iterator;
|
||||
|
||||
module.exports = function () {
|
||||
var str = "🙈f", iterator, result;
|
||||
if (typeof str[iteratorSymbol] !== "function") return false;
|
||||
iterator = str[iteratorSymbol]();
|
||||
if (!iterator) return false;
|
||||
if (typeof iterator.next !== "function") return false;
|
||||
result = iterator.next();
|
||||
if (!result) return false;
|
||||
if (result.value !== "🙈") return false;
|
||||
if (result.done !== false) return false;
|
||||
return true;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Scheduler } from '../Scheduler';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { SchedulerAction } from '../types';
|
||||
/**
|
||||
* A unit of work to be executed in a `scheduler`. An action is typically
|
||||
* created from within a {@link SchedulerLike} and an RxJS user does not need to concern
|
||||
* themselves about creating and manipulating an Action.
|
||||
*
|
||||
* ```ts
|
||||
* class Action<T> extends Subscription {
|
||||
* new (scheduler: Scheduler, work: (state?: T) => void);
|
||||
* schedule(state?: T, delay: number = 0): Subscription;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @class Action<T>
|
||||
*/
|
||||
export declare class Action<T> extends Subscription {
|
||||
constructor(scheduler: Scheduler, work: (this: SchedulerAction<T>, state?: T) => void);
|
||||
/**
|
||||
* Schedules this action on its parent {@link SchedulerLike} for execution. May be passed
|
||||
* some context object, `state`. May happen at some point in the future,
|
||||
* according to the `delay` parameter, if specified.
|
||||
* @param {T} [state] Some contextual data that the `work` function uses when
|
||||
* called by the Scheduler.
|
||||
* @param {number} [delay] Time to wait before executing the work, where the
|
||||
* time unit is implicit and defined by the Scheduler.
|
||||
* @return {void}
|
||||
*/
|
||||
schedule(state?: T, delay?: number): Subscription;
|
||||
}
|
||||
//# sourceMappingURL=Action.d.ts.map
|
||||
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var callBound = require('call-bind/callBound');
|
||||
var $charAt = callBound('String.prototype.charAt');
|
||||
var $stringToString = callBound('String.prototype.toString');
|
||||
|
||||
var CanonicalNumericIndexString = require('./CanonicalNumericIndexString');
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var IsPropertyKey = require('./IsPropertyKey');
|
||||
var Type = require('./Type');
|
||||
|
||||
var isNegativeZero = require('is-negative-zero');
|
||||
|
||||
// https://262.ecma-international.org/12.0/#sec-stringgetownproperty
|
||||
|
||||
module.exports = function StringGetOwnProperty(S, P) {
|
||||
var str;
|
||||
if (Type(S) === 'Object') {
|
||||
try {
|
||||
str = $stringToString(S);
|
||||
} catch (e) { /**/ }
|
||||
}
|
||||
if (Type(str) !== 'String') {
|
||||
throw new $TypeError('Assertion failed: `S` must be a boxed string object');
|
||||
}
|
||||
if (!IsPropertyKey(P)) {
|
||||
throw new $TypeError('Assertion failed: IsPropertyKey(P) is not true');
|
||||
}
|
||||
if (Type(P) !== 'String') {
|
||||
return void undefined;
|
||||
}
|
||||
var index = CanonicalNumericIndexString(P);
|
||||
var len = str.length;
|
||||
if (typeof index === 'undefined' || !IsIntegralNumber(index) || isNegativeZero(index) || index < 0 || len <= index) {
|
||||
return void undefined;
|
||||
}
|
||||
var resultStr = $charAt(S, index);
|
||||
return {
|
||||
'[[Configurable]]': false,
|
||||
'[[Enumerable]]': true,
|
||||
'[[Value]]': resultStr,
|
||||
'[[Writable]]': false
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
# estree-walker
|
||||
|
||||
Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm i estree-walker
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var walk = require( 'estree-walker' ).walk;
|
||||
var acorn = require( 'acorn' );
|
||||
|
||||
ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn
|
||||
|
||||
walk( ast, {
|
||||
enter: function ( node, parent, prop, index ) {
|
||||
// some code happens
|
||||
},
|
||||
leave: function ( node, parent, prop, index ) {
|
||||
// some code happens
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.
|
||||
|
||||
Call `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.
|
||||
|
||||
Call `this.remove()` in either `enter` or `leave` to remove the current node.
|
||||
|
||||
## Why not use estraverse?
|
||||
|
||||
The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.
|
||||
|
||||
estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)
|
||||
|
||||
None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,50 @@
|
||||
import {htmlEscape} from 'escape-goat';
|
||||
|
||||
export class MissingValueError extends Error {
|
||||
constructor(key) {
|
||||
super(`Missing a value for ${key ? `the placeholder: ${key}` : 'a placeholder'}`, key);
|
||||
this.name = 'MissingValueError';
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
export default function pupa(template, data, {ignoreMissing = false, transform = ({value}) => value} = {}) {
|
||||
if (typeof template !== 'string') {
|
||||
throw new TypeError(`Expected a \`string\` in the first argument, got \`${typeof template}\``);
|
||||
}
|
||||
|
||||
if (typeof data !== 'object') {
|
||||
throw new TypeError(`Expected an \`object\` or \`Array\` in the second argument, got \`${typeof data}\``);
|
||||
}
|
||||
|
||||
const replace = (placeholder, key) => {
|
||||
let value = data;
|
||||
for (const property of key.split('.')) {
|
||||
value = value ? value[property] : undefined;
|
||||
}
|
||||
|
||||
const transformedValue = transform({value, key});
|
||||
if (transformedValue === undefined) {
|
||||
if (ignoreMissing) {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
throw new MissingValueError(key);
|
||||
}
|
||||
|
||||
return String(transformedValue);
|
||||
};
|
||||
|
||||
const composeHtmlEscape = replacer => (...args) => htmlEscape(replacer(...args));
|
||||
|
||||
// The regex tries to match either a number inside `{{ }}` or a valid JS identifier or key path.
|
||||
const doubleBraceRegex = /{{(\d+|[a-z$_][\w\-$]*?(?:\.[\w\-$]*?)*?)}}/gi;
|
||||
|
||||
if (doubleBraceRegex.test(template)) {
|
||||
template = template.replace(doubleBraceRegex, composeHtmlEscape(replace));
|
||||
}
|
||||
|
||||
const braceRegex = /{(\d+|[a-z$_][\w\-$]*?(?:\.[\w\-$]*?)*?)}/gi;
|
||||
|
||||
return template.replace(braceRegex, replace);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $String = GetIntrinsic('%String%');
|
||||
var $RangeError = GetIntrinsic('%RangeError%');
|
||||
|
||||
var IsIntegralNumber = require('./IsIntegralNumber');
|
||||
var StringPad = require('./StringPad');
|
||||
|
||||
// https://262.ecma-international.org/13.0/#sec-tozeropaddeddecimalstring
|
||||
|
||||
module.exports = function ToZeroPaddedDecimalString(n, minLength) {
|
||||
if (!IsIntegralNumber(n) || n < 0) {
|
||||
throw new $RangeError('Assertion failed: `q` must be a non-negative integer');
|
||||
}
|
||||
var S = $String(n);
|
||||
return StringPad(S, minLength, '0', 'start');
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "has-flag",
|
||||
"version": "3.0.0",
|
||||
"description": "Check if argv has a specific flag",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/has-flag",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"has",
|
||||
"check",
|
||||
"detect",
|
||||
"contains",
|
||||
"find",
|
||||
"flag",
|
||||
"cli",
|
||||
"command-line",
|
||||
"argv",
|
||||
"process",
|
||||
"arg",
|
||||
"args",
|
||||
"argument",
|
||||
"arguments",
|
||||
"getopt",
|
||||
"minimist",
|
||||
"optimist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
if (!require("./is-implemented")()) {
|
||||
Object.defineProperty(String.prototype, "endsWith", {
|
||||
value: require("./shim"),
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
var assign = require('./helpers/assign');
|
||||
|
||||
var ES5 = require('./es5');
|
||||
var ES2015 = require('./es2015');
|
||||
var ES2016 = require('./es2016');
|
||||
var ES2017 = require('./es2017');
|
||||
var ES2018 = require('./es2018');
|
||||
var ES2019 = require('./es2019');
|
||||
var ES2020 = require('./es2020');
|
||||
var ES2021 = require('./es2021');
|
||||
var ES2022 = require('./es2022');
|
||||
|
||||
var ES = {
|
||||
ES5: ES5,
|
||||
ES6: ES2015,
|
||||
ES2015: ES2015,
|
||||
ES7: ES2016,
|
||||
ES2016: ES2016,
|
||||
ES2017: ES2017,
|
||||
ES2018: ES2018,
|
||||
ES2019: ES2019,
|
||||
ES2020: ES2020,
|
||||
ES2021: ES2021,
|
||||
ES2022: ES2022
|
||||
};
|
||||
assign(ES, ES5);
|
||||
delete ES.CheckObjectCoercible; // renamed in ES6 to RequireObjectCoercible
|
||||
assign(ES, ES2015);
|
||||
|
||||
module.exports = ES;
|
||||
@@ -0,0 +1,23 @@
|
||||
import { SvelteComponentTyped } from "svelte";
|
||||
import { type DataHandler } from './core';
|
||||
declare const __propDef: {
|
||||
props: {
|
||||
handler: DataHandler;
|
||||
search?: boolean;
|
||||
rowsPerPage?: boolean;
|
||||
rowCount?: boolean;
|
||||
pagination?: boolean;
|
||||
};
|
||||
events: {
|
||||
[evt: string]: CustomEvent<any>;
|
||||
};
|
||||
slots: {
|
||||
default: {};
|
||||
};
|
||||
};
|
||||
export type DatatableProps = typeof __propDef.props;
|
||||
export type DatatableEvents = typeof __propDef.events;
|
||||
export type DatatableSlots = typeof __propDef.slots;
|
||||
export default class Datatable extends SvelteComponentTyped<DatatableProps, DatatableEvents, DatatableSlots> {
|
||||
}
|
||||
export {};
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Component, ComponentChild, ComponentChildren } from '../../src';
|
||||
|
||||
//
|
||||
// Suspense/lazy
|
||||
// -----------------------------------
|
||||
export function lazy<T>(loader: () => Promise<{ default: T } | T>): T;
|
||||
|
||||
export interface SuspenseProps {
|
||||
children?: ComponentChildren;
|
||||
fallback: ComponentChildren;
|
||||
}
|
||||
|
||||
export class Suspense extends Component<SuspenseProps> {
|
||||
render(): ComponentChild;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('./spread');
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","33":"C K L G M N O"},C:{"2":"0 1 2 3 4 5 6 7 8 9 DC tB I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB EC FC"},D:{"1":"UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB","258":"2"},E:{"2":"I v J D E F A B C K L G HC zB JC KC LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","258":"IC"},F:{"1":"JB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"0 1 2 3 4 5 6 7 8 9 F B C G M N O w g x y z AB BB CB DB EB FB GB HB IB KB PC QC RC SC qB AC TC rB"},G:{"2":"zB UC BC","33":"E VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B"},H:{"2":"oC"},I:{"1":"f","2":"tB I pC qC rC sC BC tC uC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"33":"H"},N:{"161":"A B"},O:{"1":"vC"},P:{"1":"g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C","2":"I"},Q:{"1":"1B"},R:{"1":"9C"},S:{"2":"AD BD"}},B:7,C:"CSS text-size-adjust"};
|
||||
@@ -0,0 +1,6 @@
|
||||
export type ResponseRunnerCard = {
|
||||
id: number;
|
||||
runner: any;
|
||||
code: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":23.87252,"53":0,"54":0,"55":0,"56":0.0067,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.03351,"79":0.0067,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0.02011,"103":0,"104":0.0067,"105":0,"106":0.0067,"107":0,"108":0.0067,"109":0.38201,"110":0.20106,"111":0,"112":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0.0067,"49":0.07372,"50":0,"51":0.0067,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0.0067,"72":0,"73":0,"74":0.0067,"75":0.0067,"76":0,"77":0,"78":0.13404,"79":0.0134,"80":0.02011,"81":0.0067,"83":0,"84":0.0067,"85":0.03351,"86":0.02681,"87":0.0134,"88":0.0067,"89":0.0134,"90":0.0067,"91":0.0134,"92":0.0067,"93":0,"94":0,"95":0,"96":0.06032,"97":0.0134,"98":0.02011,"99":0.0067,"100":0.0134,"101":0.06032,"102":0.03351,"103":0.24797,"104":0.02011,"105":0.06702,"106":0.04691,"107":0.58307,"108":0.3284,"109":10.56905,"110":4.40992,"111":0.02011,"112":0.0134,"113":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0.02011,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0.0067,"82":0,"83":0,"84":0,"85":0.0134,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.0134,"94":0.21446,"95":0.25468,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0.0067,"15":0,"16":0.04021,"17":0,"18":0,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0.0067,"108":0.0067,"109":0.26138,"110":0.3418},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0.02011,"15":0.0067,_:"0","3.1":0,"3.2":0,"5.1":0.02681,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0.04021,"14.1":0.03351,"15.1":0.0067,"15.2-15.3":0.0067,"15.4":0.0134,"15.5":0.04691,"15.6":0.10053,"16.0":0.0134,"16.1":0.08713,"16.2":0.15415,"16.3":0.22117,"16.4":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0.00202,"7.0-7.1":0.00808,"8.1-8.4":0,"9.0-9.2":0.0101,"9.3":0.10302,"10.0-10.2":0,"10.3":0.0505,"11.0-11.2":0.00404,"11.3-11.4":0.00606,"12.0-12.1":0.0101,"12.2-12.5":0.47673,"13.0-13.1":0.01212,"13.2":0.00808,"13.3":0.02222,"13.4-13.7":0.18988,"14.0-14.4":0.38179,"14.5-14.8":0.59389,"15.0-15.1":0.17776,"15.2-15.3":0.23837,"15.4":0.27271,"15.5":0.43633,"15.6":1.14941,"16.0":2.75939,"16.1":3.57347,"16.2":4.51885,"16.3":3.16542,"16.4":0.0101},P:{"4":0.02071,"20":0.36242,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0.07248,"8.2":0,"9.2":0,"10.1":0,"11.1-11.2":0.03106,"12.0":0.01035,"13.0":0.01035,"14.0":0.02071,"15.0":0.01035,"16.0":0.01035,"17.0":0.03106,"18.0":0.06213,"19.0":0.76625},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.01865,"4.2-4.3":0.00415,"4.4":0,"4.4.3-4.4.4":0.03731},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0.01468,"9":0.00734,"10":0.00734,"11":0.12478,"5.5":0},N:{"10":0,"11":0},S:{"2.5":0.0033,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.07585},H:{"0":0.14675},L:{"0":34.39087},R:{_:"0"},M:{"0":0.04617},Q:{"13.1":0}};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"displaynames.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/types/displaynames.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AAEjC,aAAK,WAAW,GAAG,MAAM,CAAA;AACzB,aAAK,UAAU,GAAG,MAAM,CAAA;AACxB,aAAK,UAAU,GAAG,MAAM,CAAA;AACxB,aAAK,YAAY,GAAG,MAAM,CAAA;AAE1B,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,KAAK,EAAE;QACL;;WAEG;QACH,QAAQ,EAAE;YACR,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;YACnC,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;YAClC,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;SAClC,CAAA;QACD,MAAM,EAAE;YACN,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YAClC,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YACjC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;SACjC,CAAA;QACD,MAAM,EAAE;YACN,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YAClC,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;YACjC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;SACjC,CAAA;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;YACpC,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;YACnC,IAAI,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;SACnC,CAAA;KACF,CAAA;IACD;;;;OAIG;IACH,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,oBAAY,sBAAsB,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAA"}
|
||||
@@ -0,0 +1,522 @@
|
||||
// hoisted class for cyclic dependency
|
||||
class Range {
|
||||
constructor (range, options) {
|
||||
options = parseOptions(options)
|
||||
|
||||
if (range instanceof Range) {
|
||||
if (
|
||||
range.loose === !!options.loose &&
|
||||
range.includePrerelease === !!options.includePrerelease
|
||||
) {
|
||||
return range
|
||||
} else {
|
||||
return new Range(range.raw, options)
|
||||
}
|
||||
}
|
||||
|
||||
if (range instanceof Comparator) {
|
||||
// just put it in the set and return
|
||||
this.raw = range.value
|
||||
this.set = [[range]]
|
||||
this.format()
|
||||
return this
|
||||
}
|
||||
|
||||
this.options = options
|
||||
this.loose = !!options.loose
|
||||
this.includePrerelease = !!options.includePrerelease
|
||||
|
||||
// First, split based on boolean or ||
|
||||
this.raw = range
|
||||
this.set = range
|
||||
.split('||')
|
||||
// map the range to a 2d array of comparators
|
||||
.map(r => this.parseRange(r.trim()))
|
||||
// throw out any comparator lists that are empty
|
||||
// this generally means that it was not a valid range, which is allowed
|
||||
// in loose mode, but will still throw if the WHOLE range is invalid.
|
||||
.filter(c => c.length)
|
||||
|
||||
if (!this.set.length) {
|
||||
throw new TypeError(`Invalid SemVer Range: ${range}`)
|
||||
}
|
||||
|
||||
// if we have any that are not the null set, throw out null sets.
|
||||
if (this.set.length > 1) {
|
||||
// keep the first one, in case they're all null sets
|
||||
const first = this.set[0]
|
||||
this.set = this.set.filter(c => !isNullSet(c[0]))
|
||||
if (this.set.length === 0) {
|
||||
this.set = [first]
|
||||
} else if (this.set.length > 1) {
|
||||
// if we have any that are *, then the range is just *
|
||||
for (const c of this.set) {
|
||||
if (c.length === 1 && isAny(c[0])) {
|
||||
this.set = [c]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.format()
|
||||
}
|
||||
|
||||
format () {
|
||||
this.range = this.set
|
||||
.map((comps) => {
|
||||
return comps.join(' ').trim()
|
||||
})
|
||||
.join('||')
|
||||
.trim()
|
||||
return this.range
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.range
|
||||
}
|
||||
|
||||
parseRange (range) {
|
||||
range = range.trim()
|
||||
|
||||
// memoize range parsing for performance.
|
||||
// this is a very hot path, and fully deterministic.
|
||||
const memoOpts = Object.keys(this.options).join(',')
|
||||
const memoKey = `parseRange:${memoOpts}:${range}`
|
||||
const cached = cache.get(memoKey)
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const loose = this.options.loose
|
||||
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
||||
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
||||
range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
|
||||
debug('hyphen replace', range)
|
||||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
||||
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
||||
debug('comparator trim', range)
|
||||
|
||||
// `~ 1.2.3` => `~1.2.3`
|
||||
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
|
||||
|
||||
// `^ 1.2.3` => `^1.2.3`
|
||||
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
|
||||
|
||||
// normalize spaces
|
||||
range = range.split(/\s+/).join(' ')
|
||||
|
||||
// At this point, the range is completely trimmed and
|
||||
// ready to be split into comparators.
|
||||
|
||||
let rangeList = range
|
||||
.split(' ')
|
||||
.map(comp => parseComparator(comp, this.options))
|
||||
.join(' ')
|
||||
.split(/\s+/)
|
||||
// >=0.0.0 is equivalent to *
|
||||
.map(comp => replaceGTE0(comp, this.options))
|
||||
|
||||
if (loose) {
|
||||
// in loose mode, throw out any that are not valid comparators
|
||||
rangeList = rangeList.filter(comp => {
|
||||
debug('loose invalid filter', comp, this.options)
|
||||
return !!comp.match(re[t.COMPARATORLOOSE])
|
||||
})
|
||||
}
|
||||
debug('range list', rangeList)
|
||||
|
||||
// if any comparators are the null set, then replace with JUST null set
|
||||
// if more than one comparator, remove any * comparators
|
||||
// also, don't include the same comparator more than once
|
||||
const rangeMap = new Map()
|
||||
const comparators = rangeList.map(comp => new Comparator(comp, this.options))
|
||||
for (const comp of comparators) {
|
||||
if (isNullSet(comp)) {
|
||||
return [comp]
|
||||
}
|
||||
rangeMap.set(comp.value, comp)
|
||||
}
|
||||
if (rangeMap.size > 1 && rangeMap.has('')) {
|
||||
rangeMap.delete('')
|
||||
}
|
||||
|
||||
const result = [...rangeMap.values()]
|
||||
cache.set(memoKey, result)
|
||||
return result
|
||||
}
|
||||
|
||||
intersects (range, options) {
|
||||
if (!(range instanceof Range)) {
|
||||
throw new TypeError('a Range is required')
|
||||
}
|
||||
|
||||
return this.set.some((thisComparators) => {
|
||||
return (
|
||||
isSatisfiable(thisComparators, options) &&
|
||||
range.set.some((rangeComparators) => {
|
||||
return (
|
||||
isSatisfiable(rangeComparators, options) &&
|
||||
thisComparators.every((thisComparator) => {
|
||||
return rangeComparators.every((rangeComparator) => {
|
||||
return thisComparator.intersects(rangeComparator, options)
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// if ANY of the sets match ALL of its comparators, then pass
|
||||
test (version) {
|
||||
if (!version) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof version === 'string') {
|
||||
try {
|
||||
version = new SemVer(version, this.options)
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.set.length; i++) {
|
||||
if (testSet(this.set[i], version, this.options)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
module.exports = Range
|
||||
|
||||
const LRU = require('lru-cache')
|
||||
const cache = new LRU({ max: 1000 })
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const Comparator = require('./comparator')
|
||||
const debug = require('../internal/debug')
|
||||
const SemVer = require('./semver')
|
||||
const {
|
||||
re,
|
||||
t,
|
||||
comparatorTrimReplace,
|
||||
tildeTrimReplace,
|
||||
caretTrimReplace,
|
||||
} = require('../internal/re')
|
||||
|
||||
const isNullSet = c => c.value === '<0.0.0-0'
|
||||
const isAny = c => c.value === ''
|
||||
|
||||
// take a set of comparators and determine whether there
|
||||
// exists a version which can satisfy it
|
||||
const isSatisfiable = (comparators, options) => {
|
||||
let result = true
|
||||
const remainingComparators = comparators.slice()
|
||||
let testComparator = remainingComparators.pop()
|
||||
|
||||
while (result && remainingComparators.length) {
|
||||
result = remainingComparators.every((otherComparator) => {
|
||||
return testComparator.intersects(otherComparator, options)
|
||||
})
|
||||
|
||||
testComparator = remainingComparators.pop()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
||||
// already replaced the hyphen ranges
|
||||
// turn into a set of JUST comparators.
|
||||
const parseComparator = (comp, options) => {
|
||||
debug('comp', comp, options)
|
||||
comp = replaceCarets(comp, options)
|
||||
debug('caret', comp)
|
||||
comp = replaceTildes(comp, options)
|
||||
debug('tildes', comp)
|
||||
comp = replaceXRanges(comp, options)
|
||||
debug('xrange', comp)
|
||||
comp = replaceStars(comp, options)
|
||||
debug('stars', comp)
|
||||
return comp
|
||||
}
|
||||
|
||||
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
||||
|
||||
// ~, ~> --> * (any, kinda silly)
|
||||
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
||||
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
||||
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
||||
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
||||
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
||||
const replaceTildes = (comp, options) =>
|
||||
comp.trim().split(/\s+/).map((c) => {
|
||||
return replaceTilde(c, options)
|
||||
}).join(' ')
|
||||
|
||||
const replaceTilde = (comp, options) => {
|
||||
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
|
||||
return comp.replace(r, (_, M, m, p, pr) => {
|
||||
debug('tilde', comp, _, M, m, p, pr)
|
||||
let ret
|
||||
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
// ~1.2 == >=1.2.0 <1.3.0-0
|
||||
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
|
||||
} else if (pr) {
|
||||
debug('replaceTilde pr', pr)
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('tilde return', ret)
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
// ^ --> * (any, kinda silly)
|
||||
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
||||
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
||||
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
||||
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
||||
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
||||
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
||||
const replaceCarets = (comp, options) =>
|
||||
comp.trim().split(/\s+/).map((c) => {
|
||||
return replaceCaret(c, options)
|
||||
}).join(' ')
|
||||
|
||||
const replaceCaret = (comp, options) => {
|
||||
debug('caret', comp, options)
|
||||
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
||||
const z = options.includePrerelease ? '-0' : ''
|
||||
return comp.replace(r, (_, M, m, p, pr) => {
|
||||
debug('caret', comp, _, M, m, p, pr)
|
||||
let ret
|
||||
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
if (M === '0') {
|
||||
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else if (pr) {
|
||||
debug('replaceCaret pr', pr)
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else {
|
||||
debug('no pr')
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p
|
||||
}${z} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
}${z} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
}
|
||||
|
||||
debug('caret return', ret)
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
const replaceXRanges = (comp, options) => {
|
||||
debug('replaceXRanges', comp, options)
|
||||
return comp.split(/\s+/).map((c) => {
|
||||
return replaceXRange(c, options)
|
||||
}).join(' ')
|
||||
}
|
||||
|
||||
const replaceXRange = (comp, options) => {
|
||||
comp = comp.trim()
|
||||
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
|
||||
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
||||
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
||||
const xM = isX(M)
|
||||
const xm = xM || isX(m)
|
||||
const xp = xm || isX(p)
|
||||
const anyX = xp
|
||||
|
||||
if (gtlt === '=' && anyX) {
|
||||
gtlt = ''
|
||||
}
|
||||
|
||||
// if we're including prereleases in the match, then we need
|
||||
// to fix this to -0, the lowest possible prerelease value
|
||||
pr = options.includePrerelease ? '-0' : ''
|
||||
|
||||
if (xM) {
|
||||
if (gtlt === '>' || gtlt === '<') {
|
||||
// nothing is allowed
|
||||
ret = '<0.0.0-0'
|
||||
} else {
|
||||
// nothing is forbidden
|
||||
ret = '*'
|
||||
}
|
||||
} else if (gtlt && anyX) {
|
||||
// we know patch is an x, because we have any x at all.
|
||||
// replace X with 0
|
||||
if (xm) {
|
||||
m = 0
|
||||
}
|
||||
p = 0
|
||||
|
||||
if (gtlt === '>') {
|
||||
// >1 => >=2.0.0
|
||||
// >1.2 => >=1.3.0
|
||||
gtlt = '>='
|
||||
if (xm) {
|
||||
M = +M + 1
|
||||
m = 0
|
||||
p = 0
|
||||
} else {
|
||||
m = +m + 1
|
||||
p = 0
|
||||
}
|
||||
} else if (gtlt === '<=') {
|
||||
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
||||
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
||||
gtlt = '<'
|
||||
if (xm) {
|
||||
M = +M + 1
|
||||
} else {
|
||||
m = +m + 1
|
||||
}
|
||||
}
|
||||
|
||||
if (gtlt === '<') {
|
||||
pr = '-0'
|
||||
}
|
||||
|
||||
ret = `${gtlt + M}.${m}.${p}${pr}`
|
||||
} else if (xm) {
|
||||
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`
|
||||
} else if (xp) {
|
||||
ret = `>=${M}.${m}.0${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('xRange return', ret)
|
||||
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
// Because * is AND-ed with everything else in the comparator,
|
||||
// and '' means "any version", just remove the *s entirely.
|
||||
const replaceStars = (comp, options) => {
|
||||
debug('replaceStars', comp, options)
|
||||
// Looseness is ignored here. star is always as loose as it gets!
|
||||
return comp.trim().replace(re[t.STAR], '')
|
||||
}
|
||||
|
||||
const replaceGTE0 = (comp, options) => {
|
||||
debug('replaceGTE0', comp, options)
|
||||
return comp.trim()
|
||||
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
||||
}
|
||||
|
||||
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
||||
// M, m, patch, prerelease, build
|
||||
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
||||
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
||||
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
||||
const hyphenReplace = incPr => ($0,
|
||||
from, fM, fm, fp, fpr, fb,
|
||||
to, tM, tm, tp, tpr, tb) => {
|
||||
if (isX(fM)) {
|
||||
from = ''
|
||||
} else if (isX(fm)) {
|
||||
from = `>=${fM}.0.0${incPr ? '-0' : ''}`
|
||||
} else if (isX(fp)) {
|
||||
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
|
||||
} else if (fpr) {
|
||||
from = `>=${from}`
|
||||
} else {
|
||||
from = `>=${from}${incPr ? '-0' : ''}`
|
||||
}
|
||||
|
||||
if (isX(tM)) {
|
||||
to = ''
|
||||
} else if (isX(tm)) {
|
||||
to = `<${+tM + 1}.0.0-0`
|
||||
} else if (isX(tp)) {
|
||||
to = `<${tM}.${+tm + 1}.0-0`
|
||||
} else if (tpr) {
|
||||
to = `<=${tM}.${tm}.${tp}-${tpr}`
|
||||
} else if (incPr) {
|
||||
to = `<${tM}.${tm}.${+tp + 1}-0`
|
||||
} else {
|
||||
to = `<=${to}`
|
||||
}
|
||||
|
||||
return (`${from} ${to}`).trim()
|
||||
}
|
||||
|
||||
const testSet = (set, version, options) => {
|
||||
for (let i = 0; i < set.length; i++) {
|
||||
if (!set[i].test(version)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (version.prerelease.length && !options.includePrerelease) {
|
||||
// Find the set of versions that are allowed to have prereleases
|
||||
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
||||
// That should allow `1.2.3-pr.2` to pass.
|
||||
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
||||
// even though it's within the range set by the comparators.
|
||||
for (let i = 0; i < set.length; i++) {
|
||||
debug(set[i].semver)
|
||||
if (set[i].semver === Comparator.ANY) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (set[i].semver.prerelease.length > 0) {
|
||||
const allowed = set[i].semver
|
||||
if (allowed.major === version.major &&
|
||||
allowed.minor === version.minor &&
|
||||
allowed.patch === version.patch) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Version has a -pre, but it's not one of the ones we like.
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('flowRight', require('../flowRight'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"48":0.00757,"52":0.01136,"71":0.01514,"88":0.00757,"97":0.00379,"98":0.03029,"99":0.00757,"102":0.01136,"103":0.00757,"104":0.00757,"105":0.01514,"106":0.01514,"107":0.0265,"108":0.04543,"109":0.8935,"110":0.65119,"111":0.00379,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 49 50 51 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 89 90 91 92 93 94 95 96 100 101 112 3.5 3.6"},D:{"38":0.00379,"42":0.00757,"49":0.01136,"66":0.00757,"68":0.01136,"69":0.01136,"70":0.00757,"72":0.00379,"73":0.00757,"75":0.04543,"76":0.01136,"77":0.01136,"78":0.00379,"79":0.09465,"80":0.01136,"81":0.01136,"83":0.01893,"84":0.00757,"86":0.00379,"87":0.01514,"88":0.0265,"90":0.00379,"91":0.43539,"92":0.01136,"93":0.01136,"94":0.00757,"95":0.00757,"96":0.03029,"97":0.07951,"98":0.01893,"99":0.03407,"100":0.04922,"101":0.01893,"102":0.06058,"103":0.15523,"104":0.06815,"105":0.06058,"106":0.06058,"107":0.12115,"108":0.35967,"109":15.59832,"110":9.34006,"111":0.02272,"112":0.00757,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 39 40 41 43 44 45 46 47 48 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 67 71 74 85 89 113"},F:{"85":0.00379,"93":0.04543,"94":0.8935,"95":0.45053,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 86 87 88 89 90 91 92 9.5-9.6 10.5 10.6 11.1 11.5 11.6 12.1","10.0-10.1":0},B:{"14":0.00379,"18":0.01514,"84":0.00757,"85":0.00757,"92":0.02272,"102":0.00757,"103":0.01514,"104":0.01136,"105":0.01136,"106":0.00757,"107":0.04922,"108":0.04165,"109":1.18123,"110":1.64312,_:"12 13 15 16 17 79 80 81 83 86 87 88 89 90 91 93 94 95 96 97 98 99 100 101"},E:{"4":0,"14":0.01136,"15":0.00379,_:"0 5 6 7 8 9 10 11 12 13 3.1 3.2 6.1 7.1 9.1 10.1 11.1 12.1 15.2-15.3 16.4","5.1":0.01514,"13.1":0.04543,"14.1":0.06058,"15.1":0.03407,"15.4":0.01893,"15.5":0.053,"15.6":0.16658,"16.0":0.04165,"16.1":0.06058,"16.2":0.14765,"16.3":0.10979},G:{"8":0,"3.2":0,"4.0-4.1":0.00821,"4.2-4.3":0,"5.0-5.1":0.00299,"6.0-6.1":0,"7.0-7.1":0.02463,"8.1-8.4":0,"9.0-9.2":0,"9.3":0.02538,"10.0-10.2":0,"10.3":0.01119,"11.0-11.2":0.00672,"11.3-11.4":0.00299,"12.0-12.1":0.00299,"12.2-12.5":0.18658,"13.0-13.1":0.00448,"13.2":0.00149,"13.3":0.00522,"13.4-13.7":0.02687,"14.0-14.4":0.09329,"14.5-14.8":0.19479,"15.0-15.1":0.05971,"15.2-15.3":0.06568,"15.4":0.11568,"15.5":0.17837,"15.6":0.43735,"16.0":0.92694,"16.1":1.56804,"16.2":1.62327,"16.3":1.08666,"16.4":0.00299},P:{"4":0.2888,"20":0.68074,"5.0-5.4":0.01042,"6.2-6.4":0.0206,"7.2-7.4":0.38163,"8.2":0.02044,"9.2":0.04126,"10.1":0.0217,"11.1-11.2":0.10314,"12.0":0.01031,"13.0":0.04126,"14.0":0.05157,"15.0":0.04126,"16.0":0.23723,"17.0":0.17534,"18.0":0.18566,"19.0":1.63997},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00233,"4.2-4.3":0.00233,"4.4":0,"4.4.3-4.4.4":0.03263},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"11":0.03407,_:"6 7 8 9 10 5.5"},N:{"10":0.03712,"11":0.07423},S:{"2.5":0.00622,_:"3.0-3.1"},J:{"7":0,"10":0},O:{"0":0.15538},H:{"0":0.35892},L:{"0":54.45033},R:{_:"0"},M:{"0":0.13673},Q:{"13.1":0}};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('./xorBy');
|
||||
@@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const ini = require('ini');
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
|
||||
const readRc = filePath => {
|
||||
try {
|
||||
return ini.parse(fs.readFileSync(filePath, 'utf8')).prefix;
|
||||
} catch {}
|
||||
};
|
||||
|
||||
const getEnvNpmPrefix = () => {
|
||||
// TODO: Remove the `.reduce` call.
|
||||
// eslint-disable-next-line unicorn/no-array-reduce
|
||||
return Object.keys(process.env).reduce((prefix, name) => {
|
||||
return /^npm_config_prefix$/i.test(name) ? process.env[name] : prefix;
|
||||
}, undefined);
|
||||
};
|
||||
|
||||
const getGlobalNpmrc = () => {
|
||||
if (isWindows && process.env.APPDATA) {
|
||||
// Hardcoded contents of `c:\Program Files\nodejs\node_modules\npm\npmrc`
|
||||
return path.join(process.env.APPDATA, '/npm/etc/npmrc');
|
||||
}
|
||||
|
||||
// Homebrew special case: `$(brew --prefix)/lib/node_modules/npm/npmrc`
|
||||
if (process.execPath.includes('/Cellar/node')) {
|
||||
const homebrewPrefix = process.execPath.slice(0, process.execPath.indexOf('/Cellar/node'));
|
||||
return path.join(homebrewPrefix, '/lib/node_modules/npm/npmrc');
|
||||
}
|
||||
|
||||
if (process.execPath.endsWith('/bin/node')) {
|
||||
const installDir = path.dirname(path.dirname(process.execPath));
|
||||
return path.join(installDir, '/etc/npmrc');
|
||||
}
|
||||
};
|
||||
|
||||
const getDefaultNpmPrefix = () => {
|
||||
if (isWindows) {
|
||||
const {APPDATA} = process.env;
|
||||
// `c:\node\node.exe` → `prefix=c:\node\`
|
||||
return APPDATA ? path.join(APPDATA, 'npm') : path.dirname(process.execPath);
|
||||
}
|
||||
|
||||
// `/usr/local/bin/node` → `prefix=/usr/local`
|
||||
return path.dirname(path.dirname(process.execPath));
|
||||
};
|
||||
|
||||
const getNpmPrefix = () => {
|
||||
const envPrefix = getEnvNpmPrefix();
|
||||
if (envPrefix) {
|
||||
return envPrefix;
|
||||
}
|
||||
|
||||
const homePrefix = readRc(path.join(os.homedir(), '.npmrc'));
|
||||
if (homePrefix) {
|
||||
return homePrefix;
|
||||
}
|
||||
|
||||
if (process.env.PREFIX) {
|
||||
return process.env.PREFIX;
|
||||
}
|
||||
|
||||
const globalPrefix = readRc(getGlobalNpmrc());
|
||||
if (globalPrefix) {
|
||||
return globalPrefix;
|
||||
}
|
||||
|
||||
return getDefaultNpmPrefix();
|
||||
};
|
||||
|
||||
const npmPrefix = path.resolve(getNpmPrefix());
|
||||
|
||||
const getYarnWindowsDirectory = () => {
|
||||
if (isWindows && process.env.LOCALAPPDATA) {
|
||||
const dir = path.join(process.env.LOCALAPPDATA, 'Yarn');
|
||||
if (fs.existsSync(dir)) {
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const getYarnPrefix = () => {
|
||||
if (process.env.PREFIX) {
|
||||
return process.env.PREFIX;
|
||||
}
|
||||
|
||||
const windowsPrefix = getYarnWindowsDirectory();
|
||||
if (windowsPrefix) {
|
||||
return windowsPrefix;
|
||||
}
|
||||
|
||||
const configPrefix = path.join(os.homedir(), '.config/yarn');
|
||||
if (fs.existsSync(configPrefix)) {
|
||||
return configPrefix;
|
||||
}
|
||||
|
||||
const homePrefix = path.join(os.homedir(), '.yarn-config');
|
||||
if (fs.existsSync(homePrefix)) {
|
||||
return homePrefix;
|
||||
}
|
||||
|
||||
// Yarn supports the npm conventions but the inverse is not true
|
||||
return npmPrefix;
|
||||
};
|
||||
|
||||
exports.npm = {};
|
||||
exports.npm.prefix = npmPrefix;
|
||||
exports.npm.packages = path.join(npmPrefix, isWindows ? 'node_modules' : 'lib/node_modules');
|
||||
exports.npm.binaries = isWindows ? npmPrefix : path.join(npmPrefix, 'bin');
|
||||
|
||||
const yarnPrefix = path.resolve(getYarnPrefix());
|
||||
exports.yarn = {};
|
||||
exports.yarn.prefix = yarnPrefix;
|
||||
exports.yarn.packages = path.join(yarnPrefix, getYarnWindowsDirectory() ? 'Data/global/node_modules' : 'global/node_modules');
|
||||
exports.yarn.binaries = path.join(exports.yarn.packages, '.bin');
|
||||
@@ -0,0 +1,33 @@
|
||||
import os from 'node:os';
|
||||
|
||||
const nameMap = new Map([
|
||||
[22, ['Ventura', '13']],
|
||||
[21, ['Monterey', '12']],
|
||||
[20, ['Big Sur', '11']],
|
||||
[19, ['Catalina', '10.15']],
|
||||
[18, ['Mojave', '10.14']],
|
||||
[17, ['High Sierra', '10.13']],
|
||||
[16, ['Sierra', '10.12']],
|
||||
[15, ['El Capitan', '10.11']],
|
||||
[14, ['Yosemite', '10.10']],
|
||||
[13, ['Mavericks', '10.9']],
|
||||
[12, ['Mountain Lion', '10.8']],
|
||||
[11, ['Lion', '10.7']],
|
||||
[10, ['Snow Leopard', '10.6']],
|
||||
[9, ['Leopard', '10.5']],
|
||||
[8, ['Tiger', '10.4']],
|
||||
[7, ['Panther', '10.3']],
|
||||
[6, ['Jaguar', '10.2']],
|
||||
[5, ['Puma', '10.1']],
|
||||
]);
|
||||
|
||||
export default function macosRelease(release) {
|
||||
release = Number((release || os.release()).split('.')[0]);
|
||||
|
||||
const [name, version] = nameMap.get(release) || ['Unknown', ''];
|
||||
|
||||
return {
|
||||
name,
|
||||
version,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import { __asyncValues, __awaiter, __generator, __values } from "tslib";
|
||||
import { isArrayLike } from '../util/isArrayLike';
|
||||
import { isPromise } from '../util/isPromise';
|
||||
import { Observable } from '../Observable';
|
||||
import { isInteropObservable } from '../util/isInteropObservable';
|
||||
import { isAsyncIterable } from '../util/isAsyncIterable';
|
||||
import { createInvalidObservableTypeError } from '../util/throwUnobservableError';
|
||||
import { isIterable } from '../util/isIterable';
|
||||
import { isReadableStreamLike, readableStreamLikeToAsyncGenerator } from '../util/isReadableStreamLike';
|
||||
import { isFunction } from '../util/isFunction';
|
||||
import { reportUnhandledError } from '../util/reportUnhandledError';
|
||||
import { observable as Symbol_observable } from '../symbol/observable';
|
||||
export function innerFrom(input) {
|
||||
if (input instanceof Observable) {
|
||||
return input;
|
||||
}
|
||||
if (input != null) {
|
||||
if (isInteropObservable(input)) {
|
||||
return fromInteropObservable(input);
|
||||
}
|
||||
if (isArrayLike(input)) {
|
||||
return fromArrayLike(input);
|
||||
}
|
||||
if (isPromise(input)) {
|
||||
return fromPromise(input);
|
||||
}
|
||||
if (isAsyncIterable(input)) {
|
||||
return fromAsyncIterable(input);
|
||||
}
|
||||
if (isIterable(input)) {
|
||||
return fromIterable(input);
|
||||
}
|
||||
if (isReadableStreamLike(input)) {
|
||||
return fromReadableStreamLike(input);
|
||||
}
|
||||
}
|
||||
throw createInvalidObservableTypeError(input);
|
||||
}
|
||||
export function fromInteropObservable(obj) {
|
||||
return new Observable(function (subscriber) {
|
||||
var obs = obj[Symbol_observable]();
|
||||
if (isFunction(obs.subscribe)) {
|
||||
return obs.subscribe(subscriber);
|
||||
}
|
||||
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
||||
});
|
||||
}
|
||||
export function fromArrayLike(array) {
|
||||
return new Observable(function (subscriber) {
|
||||
for (var i = 0; i < array.length && !subscriber.closed; i++) {
|
||||
subscriber.next(array[i]);
|
||||
}
|
||||
subscriber.complete();
|
||||
});
|
||||
}
|
||||
export function fromPromise(promise) {
|
||||
return new Observable(function (subscriber) {
|
||||
promise
|
||||
.then(function (value) {
|
||||
if (!subscriber.closed) {
|
||||
subscriber.next(value);
|
||||
subscriber.complete();
|
||||
}
|
||||
}, function (err) { return subscriber.error(err); })
|
||||
.then(null, reportUnhandledError);
|
||||
});
|
||||
}
|
||||
export function fromIterable(iterable) {
|
||||
return new Observable(function (subscriber) {
|
||||
var e_1, _a;
|
||||
try {
|
||||
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
||||
var value = iterable_1_1.value;
|
||||
subscriber.next(value);
|
||||
if (subscriber.closed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
subscriber.complete();
|
||||
});
|
||||
}
|
||||
export function fromAsyncIterable(asyncIterable) {
|
||||
return new Observable(function (subscriber) {
|
||||
process(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); });
|
||||
});
|
||||
}
|
||||
export function fromReadableStreamLike(readableStream) {
|
||||
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
||||
}
|
||||
function process(asyncIterable, subscriber) {
|
||||
var asyncIterable_1, asyncIterable_1_1;
|
||||
var e_2, _a;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var value, e_2_1;
|
||||
return __generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
_b.trys.push([0, 5, 6, 11]);
|
||||
asyncIterable_1 = __asyncValues(asyncIterable);
|
||||
_b.label = 1;
|
||||
case 1: return [4, asyncIterable_1.next()];
|
||||
case 2:
|
||||
if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4];
|
||||
value = asyncIterable_1_1.value;
|
||||
subscriber.next(value);
|
||||
if (subscriber.closed) {
|
||||
return [2];
|
||||
}
|
||||
_b.label = 3;
|
||||
case 3: return [3, 1];
|
||||
case 4: return [3, 11];
|
||||
case 5:
|
||||
e_2_1 = _b.sent();
|
||||
e_2 = { error: e_2_1 };
|
||||
return [3, 11];
|
||||
case 6:
|
||||
_b.trys.push([6, , 9, 10]);
|
||||
if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];
|
||||
return [4, _a.call(asyncIterable_1)];
|
||||
case 7:
|
||||
_b.sent();
|
||||
_b.label = 8;
|
||||
case 8: return [3, 10];
|
||||
case 9:
|
||||
if (e_2) throw e_2.error;
|
||||
return [7];
|
||||
case 10: return [7];
|
||||
case 11:
|
||||
subscriber.complete();
|
||||
return [2];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=innerFrom.js.map
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('toPlainObject', require('../toPlainObject'), require('./_falseOptions'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1,17 @@
|
||||
## [5.1.0](https://github.com/rvagg/bl/compare/v5.0.0...v5.1.0) (2022-10-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added integrated TypeScript typings ([#108](https://github.com/rvagg/bl/issues/108)) ([433ff89](https://github.com/rvagg/bl/commit/433ff8942f47fab8a5c9d13b2c00989ccf8d0710))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* windows support in tests ([387dfaf](https://github.com/rvagg/bl/commit/387dfaf9b2bca7849f12785436ceb01e42adac2c))
|
||||
|
||||
|
||||
### Trivial Changes
|
||||
|
||||
* GH Actions, Dependabot, auto-release, remove Travis ([997f058](https://github.com/rvagg/bl/commit/997f058357de8f2a7f66998e80a72b491835573f))
|
||||
* **no-release:** bump standard from 16.0.4 to 17.0.0 ([#112](https://github.com/rvagg/bl/issues/112)) ([078bfe3](https://github.com/rvagg/bl/commit/078bfe33390d125297b1c946e5989c4aa9228961))
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
|
||||
date|*json*employee.name|*json*employee.age|*json*employee.number|*array*address|*array*address|*jsonarray*employee.key|*jsonarray*employee.key|*omit*id
|
||||
2012-02-12|Eric|31|51234|Dunno Street|Kilkeny Road|key1|key2|2
|
||||
2012-03-06|Ted|28|51289|O FUTEBOL.¿|Tormore|key3|key4|4
|
||||
@@ -0,0 +1,5 @@
|
||||
var convert = require('./convert'),
|
||||
func = convert('pullAllBy', require('../pullAllBy'));
|
||||
|
||||
func.placeholder = require('./placeholder');
|
||||
module.exports = func;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J D E F A B CC"},B:{"1":"P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H","2":"C K L G M N O"},C:{"1":"3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB","2":"0 1 2 DC tB I v J D E F A B C K L G M N O w g x y z EC FC"},D:{"1":"DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R S T U V W X Y Z a b c d e i j k l m n o p q r s t u f H xB yB GC","2":"0 1 2 3 4 5 6 7 8 9 I v J D E F A B C K L G M N O w g x y z AB BB CB"},E:{"1":"A B C K L G LC 0B qB rB 1B MC NC 2B 3B 4B 5B sB 6B 7B 8B 9B OC","2":"I v J D E F HC zB IC JC KC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB h lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d e","2":"F B C G M N O w g x y z PC QC RC SC qB AC TC rB"},G:{"1":"aC bC cC dC eC fC gC hC iC jC kC lC mC nC 2B 3B 4B 5B sB 6B 7B 8B 9B","2":"E zB UC BC VC WC XC YC ZC"},H:{"2":"oC"},I:{"1":"f uC","2":"tB I pC qC rC sC BC tC"},J:{"2":"D A"},K:{"1":"h","2":"A B C qB AC rB"},L:{"1":"H"},M:{"1":"H"},N:{"2":"A B"},O:{"1":"vC"},P:{"1":"I g wC xC yC zC 0C 0B 1C 2C 3C 4C 5C sB 6C 7C 8C"},Q:{"1":"1B"},R:{"1":"9C"},S:{"1":"AD BD"}},B:2,C:"CSS all property"};
|
||||
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
var toPosInt = require("../../number/to-pos-integer")
|
||||
, callable = require("../../object/valid-callable")
|
||||
, value = require("../../object/valid-value")
|
||||
, objHasOwnProperty = Object.prototype.hasOwnProperty
|
||||
, call = Function.prototype.call;
|
||||
|
||||
module.exports = function (cb /*, thisArg*/) {
|
||||
var i, self, thisArg;
|
||||
|
||||
self = Object(value(this));
|
||||
callable(cb);
|
||||
thisArg = arguments[1];
|
||||
|
||||
for (i = toPosInt(self.length) - 1; i >= 0; --i) {
|
||||
if (objHasOwnProperty.call(self, i)) call.call(cb, thisArg, self[i], i, self);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
export class SubscriptionLog {
|
||||
constructor(subscribedFrame, unsubscribedFrame = Infinity) {
|
||||
this.subscribedFrame = subscribedFrame;
|
||||
this.unsubscribedFrame = unsubscribedFrame;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=SubscriptionLog.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"race.js","sourceRoot":"","sources":["../../../../src/internal/operators/race.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAAwD;AACxD,uCAAsC;AAetC,SAAgB,IAAI;IAAI,cAAc;SAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;QAAd,yBAAc;;IACpC,OAAO,mBAAQ,wCAAI,+BAAc,CAAC,IAAI,CAAC,IAAE;AAC3C,CAAC;AAFD,oBAEC"}
|
||||
@@ -0,0 +1,69 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f',
|
||||
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||||
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
||||
rsDingbatRange = '\\u2700-\\u27bf',
|
||||
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
|
||||
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
|
||||
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
|
||||
rsPunctuationRange = '\\u2000-\\u206f',
|
||||
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
|
||||
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
|
||||
rsVarRange = '\\ufe0e\\ufe0f',
|
||||
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsApos = "['\u2019]",
|
||||
rsBreak = '[' + rsBreakRange + ']',
|
||||
rsCombo = '[' + rsComboRange + ']',
|
||||
rsDigits = '\\d+',
|
||||
rsDingbat = '[' + rsDingbatRange + ']',
|
||||
rsLower = '[' + rsLowerRange + ']',
|
||||
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsUpper = '[' + rsUpperRange + ']',
|
||||
rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
|
||||
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
|
||||
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
|
||||
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
|
||||
reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
|
||||
rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
||||
|
||||
/** Used to match complex or compound words. */
|
||||
var reUnicodeWord = RegExp([
|
||||
rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
|
||||
rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
|
||||
rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
|
||||
rsUpper + '+' + rsOptContrUpper,
|
||||
rsOrdUpper,
|
||||
rsOrdLower,
|
||||
rsDigits,
|
||||
rsEmoji
|
||||
].join('|'), 'g');
|
||||
|
||||
/**
|
||||
* Splits a Unicode `string` into an array of its words.
|
||||
*
|
||||
* @private
|
||||
* @param {string} The string to inspect.
|
||||
* @returns {Array} Returns the words of `string`.
|
||||
*/
|
||||
function unicodeWords(string) {
|
||||
return string.match(reUnicodeWord) || [];
|
||||
}
|
||||
|
||||
module.exports = unicodeWords;
|
||||
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "cloneDeep", {
|
||||
enumerable: true,
|
||||
get: ()=>cloneDeep
|
||||
});
|
||||
function cloneDeep(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((child)=>cloneDeep(child));
|
||||
}
|
||||
if (typeof value === "object" && value !== null) {
|
||||
return Object.fromEntries(Object.entries(value).map(([k, v])=>[
|
||||
k,
|
||||
cloneDeep(v)
|
||||
]));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
export interface MimeBuffer extends Buffer {
|
||||
type: string;
|
||||
typeFull: string;
|
||||
charset: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a `Buffer` instance from the given data URI `uri`.
|
||||
*
|
||||
* @param {String} uri Data URI to turn into a Buffer instance
|
||||
* @returns {Buffer} Buffer instance from Data URI
|
||||
* @api public
|
||||
*/
|
||||
export function dataUriToBuffer(uri: string): MimeBuffer {
|
||||
if (!/^data:/i.test(uri)) {
|
||||
throw new TypeError(
|
||||
'`uri` does not appear to be a Data URI (must begin with "data:")'
|
||||
);
|
||||
}
|
||||
|
||||
// strip newlines
|
||||
uri = uri.replace(/\r?\n/g, '');
|
||||
|
||||
// split the URI up into the "metadata" and the "data" portions
|
||||
const firstComma = uri.indexOf(',');
|
||||
if (firstComma === -1 || firstComma <= 4) {
|
||||
throw new TypeError('malformed data: URI');
|
||||
}
|
||||
|
||||
// remove the "data:" scheme and parse the metadata
|
||||
const meta = uri.substring(5, firstComma).split(';');
|
||||
|
||||
let charset = '';
|
||||
let base64 = false;
|
||||
const type = meta[0] || 'text/plain';
|
||||
let typeFull = type;
|
||||
for (let i = 1; i < meta.length; i++) {
|
||||
if (meta[i] === 'base64') {
|
||||
base64 = true;
|
||||
} else if(meta[i]) {
|
||||
typeFull += `;${ meta[i]}`;
|
||||
if (meta[i].indexOf('charset=') === 0) {
|
||||
charset = meta[i].substring(8);
|
||||
}
|
||||
}
|
||||
}
|
||||
// defaults to US-ASCII only if type is not provided
|
||||
if (!meta[0] && !charset.length) {
|
||||
typeFull += ';charset=US-ASCII';
|
||||
charset = 'US-ASCII';
|
||||
}
|
||||
|
||||
// get the encoded data portion and decode URI-encoded chars
|
||||
const encoding = base64 ? 'base64' : 'ascii';
|
||||
const data = unescape(uri.substring(firstComma + 1));
|
||||
const buffer = Buffer.from(data, encoding) as MimeBuffer;
|
||||
|
||||
// set `.type` and `.typeFull` properties to MIME type
|
||||
buffer.type = type;
|
||||
buffer.typeFull = typeFull;
|
||||
|
||||
// set the `.charset` property
|
||||
buffer.charset = charset;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
export default dataUriToBuffer;
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Sticky bottom bar user interface
|
||||
*/
|
||||
|
||||
import through from 'through';
|
||||
import Base from './baseUI.js';
|
||||
import * as rlUtils from '../utils/readline.js';
|
||||
|
||||
export default class BottomBar extends Base {
|
||||
constructor(opt = {}) {
|
||||
super(opt);
|
||||
|
||||
this.log = through(this.writeLog.bind(this));
|
||||
this.bottomBar = opt.bottomBar || '';
|
||||
this.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the prompt to screen
|
||||
* @return {BottomBar} self
|
||||
*/
|
||||
|
||||
render() {
|
||||
this.write(this.bottomBar);
|
||||
return this;
|
||||
}
|
||||
|
||||
clean() {
|
||||
rlUtils.clearLine(this.rl, this.bottomBar.split('\n').length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the bottom bar content and rerender
|
||||
* @param {String} bottomBar Bottom bar content
|
||||
* @return {BottomBar} self
|
||||
*/
|
||||
|
||||
updateBottomBar(bottomBar) {
|
||||
rlUtils.clearLine(this.rl, 1);
|
||||
this.rl.output.unmute();
|
||||
this.clean();
|
||||
this.bottomBar = bottomBar;
|
||||
this.render();
|
||||
this.rl.output.mute();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out log data
|
||||
* @param {String} data - The log data to be output
|
||||
* @return {BottomBar} self
|
||||
*/
|
||||
|
||||
writeLog(data) {
|
||||
this.rl.output.unmute();
|
||||
this.clean();
|
||||
this.rl.output.write(this.enforceLF(data.toString()));
|
||||
this.render();
|
||||
this.rl.output.mute();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure line end on a line feed
|
||||
* @param {String} str Input string
|
||||
* @return {String} The input string with a final line feed
|
||||
*/
|
||||
|
||||
enforceLF(str) {
|
||||
return str.match(/[\r\n]$/) ? str : str + '\n';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for writing message in Prompt
|
||||
* @param {String} message - The message to be output
|
||||
*/
|
||||
write(message) {
|
||||
const msgLines = message.split(/\n/);
|
||||
this.height = msgLines.length;
|
||||
|
||||
// Write message to screen and setPrompt to control backspace
|
||||
this.rl.setPrompt(msgLines[msgLines.length - 1]);
|
||||
|
||||
if (this.rl.output.rows === 0 && this.rl.output.columns === 0) {
|
||||
/* When it's a tty through serial port there's no terminal info and the render will malfunction,
|
||||
so we need enforce the cursor to locate to the leftmost position for rendering. */
|
||||
rlUtils.left(this.rl, message.length + this.rl.line.length);
|
||||
}
|
||||
|
||||
this.rl.output.write(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"from.js","sourceRoot":"","sources":["../../../../src/internal/observable/from.ts"],"names":[],"mappings":";;;AAEA,oDAAmD;AACnD,yCAAwC;AAkGxC,SAAgB,IAAI,CAAI,KAAyB,EAAE,SAAyB;IAC1E,OAAO,SAAS,CAAC,CAAC,CAAC,qBAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,qBAAS,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC;AAFD,oBAEC"}
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var $SyntaxError = GetIntrinsic('%SyntaxError%');
|
||||
var $TypeError = GetIntrinsic('%TypeError%');
|
||||
|
||||
var isArrayBuffer = require('is-array-buffer');
|
||||
|
||||
var MessageChannel;
|
||||
try {
|
||||
// eslint-disable-next-line global-require
|
||||
MessageChannel = require('worker_threads').MessageChannel; // node 11.7+
|
||||
} catch (e) { /**/ }
|
||||
|
||||
// https://262.ecma-international.org/6.0/#sec-detacharraybuffer
|
||||
|
||||
/* globals postMessage */
|
||||
|
||||
module.exports = function DetachArrayBuffer(arrayBuffer) {
|
||||
if (!isArrayBuffer(arrayBuffer)) {
|
||||
throw new $TypeError('Assertion failed: `arrayBuffer` must be an Object with an [[ArrayBufferData]] internal slot');
|
||||
}
|
||||
if (typeof structuredClone === 'function') {
|
||||
structuredClone(arrayBuffer, { transfer: [arrayBuffer] });
|
||||
} else if (typeof postMessage === 'function') {
|
||||
postMessage('', '/', [arrayBuffer]); // TODO: see if this might trigger listeners
|
||||
} else if (MessageChannel) {
|
||||
(new MessageChannel()).port1.postMessage(null, [arrayBuffer]);
|
||||
} else {
|
||||
throw new $SyntaxError('DetachArrayBuffer is not supported in this environment');
|
||||
}
|
||||
return null;
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
# read-cache [](https://travis-ci.org/TrySound/read-cache)
|
||||
|
||||
Reads and caches the entire contents of a file until it is modified.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm i read-cache
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
var readCache = require('read-cache');
|
||||
|
||||
readCache('foo.js').then(function (contents) {
|
||||
console.log(contents);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### readCache(path[, encoding])
|
||||
|
||||
Returns a promise that resolves with the file's contents.
|
||||
|
||||
### readCache.sync(path[, encoding])
|
||||
|
||||
Returns the content of the file.
|
||||
|
||||
### readCache.get(path[, encoding])
|
||||
|
||||
Returns the content of cached file or null.
|
||||
|
||||
### readCache.clear()
|
||||
|
||||
Clears the contents of the cache.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
||||
Reference in New Issue
Block a user