123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- // node_modules/.pnpm/min-dash@4.2.1/node_modules/min-dash/dist/index.esm.js
- function flatten(arr) {
- return Array.prototype.concat.apply([], arr);
- }
- var nativeToString = Object.prototype.toString;
- var nativeHasOwnProperty = Object.prototype.hasOwnProperty;
- function isUndefined(obj) {
- return obj === void 0;
- }
- function isDefined(obj) {
- return obj !== void 0;
- }
- function isNil(obj) {
- return obj == null;
- }
- function isArray(obj) {
- return nativeToString.call(obj) === "[object Array]";
- }
- function isObject(obj) {
- return nativeToString.call(obj) === "[object Object]";
- }
- function isNumber(obj) {
- return nativeToString.call(obj) === "[object Number]";
- }
- function isFunction(obj) {
- const tag = nativeToString.call(obj);
- return tag === "[object Function]" || tag === "[object AsyncFunction]" || tag === "[object GeneratorFunction]" || tag === "[object AsyncGeneratorFunction]" || tag === "[object Proxy]";
- }
- function isString(obj) {
- return nativeToString.call(obj) === "[object String]";
- }
- function ensureArray(obj) {
- if (isArray(obj)) {
- return;
- }
- throw new Error("must supply array");
- }
- function has(target, key) {
- return nativeHasOwnProperty.call(target, key);
- }
- function find(collection, matcher) {
- const matchFn = toMatcher(matcher);
- let match;
- forEach(collection, function(val, key) {
- if (matchFn(val, key)) {
- match = val;
- return false;
- }
- });
- return match;
- }
- function findIndex(collection, matcher) {
- const matchFn = toMatcher(matcher);
- let idx = isArray(collection) ? -1 : void 0;
- forEach(collection, function(val, key) {
- if (matchFn(val, key)) {
- idx = key;
- return false;
- }
- });
- return idx;
- }
- function filter(collection, matcher) {
- const matchFn = toMatcher(matcher);
- let result = [];
- forEach(collection, function(val, key) {
- if (matchFn(val, key)) {
- result.push(val);
- }
- });
- return result;
- }
- function forEach(collection, iterator) {
- let val, result;
- if (isUndefined(collection)) {
- return;
- }
- const convertKey = isArray(collection) ? toNum : identity;
- for (let key in collection) {
- if (has(collection, key)) {
- val = collection[key];
- result = iterator(val, convertKey(key));
- if (result === false) {
- return val;
- }
- }
- }
- }
- function without(arr, matcher) {
- if (isUndefined(arr)) {
- return [];
- }
- ensureArray(arr);
- const matchFn = toMatcher(matcher);
- return arr.filter(function(el, idx) {
- return !matchFn(el, idx);
- });
- }
- function reduce(collection, iterator, result) {
- forEach(collection, function(value, idx) {
- result = iterator(result, value, idx);
- });
- return result;
- }
- function every(collection, matcher) {
- return !!reduce(collection, function(matches, val, key) {
- return matches && matcher(val, key);
- }, true);
- }
- function some(collection, matcher) {
- return !!find(collection, matcher);
- }
- function map(collection, fn) {
- let result = [];
- forEach(collection, function(val, key) {
- result.push(fn(val, key));
- });
- return result;
- }
- function keys(collection) {
- return collection && Object.keys(collection) || [];
- }
- function size(collection) {
- return keys(collection).length;
- }
- function values(collection) {
- return map(collection, (val) => val);
- }
- function groupBy(collection, extractor, grouped = {}) {
- extractor = toExtractor(extractor);
- forEach(collection, function(val) {
- let discriminator = extractor(val) || "_";
- let group = grouped[discriminator];
- if (!group) {
- group = grouped[discriminator] = [];
- }
- group.push(val);
- });
- return grouped;
- }
- function uniqueBy(extractor, ...collections) {
- extractor = toExtractor(extractor);
- let grouped = {};
- forEach(collections, (c) => groupBy(c, extractor, grouped));
- let result = map(grouped, function(val, key) {
- return val[0];
- });
- return result;
- }
- var unionBy = uniqueBy;
- function sortBy(collection, extractor) {
- extractor = toExtractor(extractor);
- let sorted = [];
- forEach(collection, function(value, key) {
- let disc = extractor(value, key);
- let entry = {
- d: disc,
- v: value
- };
- for (var idx = 0; idx < sorted.length; idx++) {
- let { d } = sorted[idx];
- if (disc < d) {
- sorted.splice(idx, 0, entry);
- return;
- }
- }
- sorted.push(entry);
- });
- return map(sorted, (e) => e.v);
- }
- function matchPattern(pattern) {
- return function(el) {
- return every(pattern, function(val, key) {
- return el[key] === val;
- });
- };
- }
- function toExtractor(extractor) {
- return isFunction(extractor) ? extractor : (e) => {
- return e[extractor];
- };
- }
- function toMatcher(matcher) {
- return isFunction(matcher) ? matcher : (e) => {
- return e === matcher;
- };
- }
- function identity(arg) {
- return arg;
- }
- function toNum(arg) {
- return Number(arg);
- }
- function debounce(fn, timeout) {
- let timer;
- let lastArgs;
- let lastThis;
- let lastNow;
- function fire(force) {
- let now = Date.now();
- let scheduledDiff = force ? 0 : lastNow + timeout - now;
- if (scheduledDiff > 0) {
- return schedule(scheduledDiff);
- }
- fn.apply(lastThis, lastArgs);
- clear();
- }
- function schedule(timeout2) {
- timer = setTimeout(fire, timeout2);
- }
- function clear() {
- if (timer) {
- clearTimeout(timer);
- }
- timer = lastNow = lastArgs = lastThis = void 0;
- }
- function flush() {
- if (timer) {
- fire(true);
- }
- clear();
- }
- function callback(...args) {
- lastNow = Date.now();
- lastArgs = args;
- lastThis = this;
- if (!timer) {
- schedule(timeout);
- }
- }
- callback.flush = flush;
- callback.cancel = clear;
- return callback;
- }
- function throttle(fn, interval) {
- let throttling = false;
- return function(...args) {
- if (throttling) {
- return;
- }
- fn(...args);
- throttling = true;
- setTimeout(() => {
- throttling = false;
- }, interval);
- };
- }
- function bind(fn, target) {
- return fn.bind(target);
- }
- function assign(target, ...others) {
- return Object.assign(target, ...others);
- }
- function set(target, path, value) {
- let currentTarget = target;
- forEach(path, function(key, idx) {
- if (typeof key !== "number" && typeof key !== "string") {
- throw new Error("illegal key type: " + typeof key + ". Key should be of type number or string.");
- }
- if (key === "constructor") {
- throw new Error("illegal key: constructor");
- }
- if (key === "__proto__") {
- throw new Error("illegal key: __proto__");
- }
- let nextKey = path[idx + 1];
- let nextTarget = currentTarget[key];
- if (isDefined(nextKey) && isNil(nextTarget)) {
- nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
- }
- if (isUndefined(nextKey)) {
- if (isUndefined(value)) {
- delete currentTarget[key];
- } else {
- currentTarget[key] = value;
- }
- } else {
- currentTarget = nextTarget;
- }
- });
- return target;
- }
- function get(target, path, defaultValue) {
- let currentTarget = target;
- forEach(path, function(key) {
- if (isNil(currentTarget)) {
- currentTarget = void 0;
- return false;
- }
- currentTarget = currentTarget[key];
- });
- return isUndefined(currentTarget) ? defaultValue : currentTarget;
- }
- function pick(target, properties) {
- let result = {};
- let obj = Object(target);
- forEach(properties, function(prop) {
- if (prop in obj) {
- result[prop] = target[prop];
- }
- });
- return result;
- }
- function omit(target, properties) {
- let result = {};
- let obj = Object(target);
- forEach(obj, function(prop, key) {
- if (properties.indexOf(key) === -1) {
- result[key] = prop;
- }
- });
- return result;
- }
- function merge(target, ...sources) {
- if (!sources.length) {
- return target;
- }
- forEach(sources, function(source) {
- if (!source || !isObject(source)) {
- return;
- }
- forEach(source, function(sourceVal, key) {
- if (key === "__proto__") {
- return;
- }
- let targetVal = target[key];
- if (isObject(sourceVal)) {
- if (!isObject(targetVal)) {
- targetVal = {};
- }
- target[key] = merge(targetVal, sourceVal);
- } else {
- target[key] = sourceVal;
- }
- });
- });
- return target;
- }
- export {
- flatten,
- isUndefined,
- isDefined,
- isNil,
- isArray,
- isObject,
- isNumber,
- isFunction,
- isString,
- ensureArray,
- has,
- find,
- findIndex,
- filter,
- forEach,
- without,
- reduce,
- every,
- some,
- map,
- keys,
- size,
- values,
- groupBy,
- uniqueBy,
- unionBy,
- sortBy,
- matchPattern,
- debounce,
- throttle,
- bind,
- assign,
- set,
- get,
- pick,
- omit,
- merge
- };
- //# sourceMappingURL=chunk-4AK4GF4H.js.map
|