UNPKG

farmos

Version:

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.

2,028 lines (1,592 loc) 119 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.model = {})); })(this, (function (exports) { 'use strict'; function _cloneRegExp$1(pattern) { return new RegExp(pattern.source, (pattern.global ? 'g' : '') + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : '') + (pattern.sticky ? 'y' : '') + (pattern.unicode ? 'u' : '')); } var _cloneRegExp_1 = _cloneRegExp$1; function _isPlaceholder$4(a) { return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true; } var _isPlaceholder_1 = _isPlaceholder$4; var _isPlaceholder$3 = _isPlaceholder_1; /** * Optimized internal one-arity curry function. * * @private * @category Function * @param {Function} fn The function to curry. * @return {Function} The curried function. */ function _curry1$g(fn) { return function f1(a) { if (arguments.length === 0 || _isPlaceholder$3(a)) { return f1; } else { return fn.apply(this, arguments); } }; } var _curry1_1 = _curry1$g; var _curry1$f = _curry1_1; /** * Gives a single-word string description of the (native) type of a value, * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not * attempt to distinguish user Object types any further, reporting them all as * 'Object'. * * @func * @memberOf R * @since v0.8.0 * @category Type * @sig (* -> {*}) -> String * @param {*} val The value to test * @return {String} * @example * * R.type({}); //=> "Object" * R.type(1); //=> "Number" * R.type(false); //=> "Boolean" * R.type('s'); //=> "String" * R.type(null); //=> "Null" * R.type([]); //=> "Array" * R.type(/[A-z]/); //=> "RegExp" * R.type(() => {}); //=> "Function" * R.type(undefined); //=> "Undefined" */ var type$2 = /*#__PURE__*/ _curry1$f(function type(val) { return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1); }); var type_1 = type$2; var _cloneRegExp = _cloneRegExp_1; var type$1 = type_1; /** * Copies an object. * * @private * @param {*} value The value to be copied * @param {Array} refFrom Array containing the source references * @param {Array} refTo Array containing the copied source references * @param {Boolean} deep Whether or not to perform deep cloning. * @return {*} The copied value. */ function _clone$1(value, refFrom, refTo, deep) { var copy = function copy(copiedValue) { var len = refFrom.length; var idx = 0; while (idx < len) { if (value === refFrom[idx]) { return refTo[idx]; } idx += 1; } refFrom[idx + 1] = value; refTo[idx + 1] = copiedValue; for (var key in value) { copiedValue[key] = deep ? _clone$1(value[key], refFrom, refTo, true) : value[key]; } return copiedValue; }; switch (type$1(value)) { case 'Object': return copy({}); case 'Array': return copy([]); case 'Date': return new Date(value.valueOf()); case 'RegExp': return _cloneRegExp(value); default: return value; } } var _clone_1 = _clone$1; var _clone = _clone_1; var _curry1$e = _curry1_1; /** * Creates a deep copy of the value which may contain (nested) `Array`s and * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are * assigned by reference rather than copied * * Dispatches to a `clone` method if present. * * @func * @memberOf R * @since v0.1.0 * @category Object * @sig {*} -> {*} * @param {*} value The object or array to clone * @return {*} A deeply cloned copy of `val` * @example * * const objects = [{}, {}, {}]; * const objectsClone = R.clone(objects); * objects === objectsClone; //=> false * objects[0] === objectsClone[0]; //=> false */ var clone = /*#__PURE__*/ _curry1$e(function clone(value) { return value != null && typeof value.clone === 'function' ? value.clone() : _clone(value, [], [], true); }); var clone_1 = clone; var clone$1 = clone_1; var _curry1$d = _curry1_1; var _isPlaceholder$2 = _isPlaceholder_1; /** * Optimized internal two-arity curry function. * * @private * @category Function * @param {Function} fn The function to curry. * @return {Function} The curried function. */ function _curry2$o(fn) { return function f2(a, b) { switch (arguments.length) { case 0: return f2; case 1: return _isPlaceholder$2(a) ? f2 : _curry1$d(function (_b) { return fn(a, _b); }); default: return _isPlaceholder$2(a) && _isPlaceholder$2(b) ? f2 : _isPlaceholder$2(a) ? _curry1$d(function (_a) { return fn(_a, b); }) : _isPlaceholder$2(b) ? _curry1$d(function (_b) { return fn(a, _b); }) : fn(a, b); } }; } var _curry2_1 = _curry2$o; /** * Tests whether or not an object is an array. * * @private * @param {*} val The object to test. * @return {Boolean} `true` if `val` is an array, `false` otherwise. * @example * * _isArray([]); //=> true * _isArray(null); //=> false * _isArray({}); //=> false */ var _isArray$3 = Array.isArray || function _isArray(val) { return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]'; }; function _isTransformer$1(obj) { return obj != null && typeof obj['@@transducer/step'] === 'function'; } var _isTransformer_1 = _isTransformer$1; var _isArray$2 = _isArray$3; var _isTransformer = _isTransformer_1; /** * Returns a function that dispatches with different strategies based on the * object in list position (last argument). If it is an array, executes [fn]. * Otherwise, if it has a function with one of the given method names, it will * execute that function (functor case). Otherwise, if it is a transformer, * uses transducer [xf] to return a new transformer (transducer case). * Otherwise, it will default to executing [fn]. * * @private * @param {Array} methodNames properties to check for a custom implementation * @param {Function} xf transducer to initialize if object is transformer * @param {Function} fn default ramda implementation * @return {Function} A function that dispatches on object in list position */ function _dispatchable$3(methodNames, xf, fn) { return function () { if (arguments.length === 0) { return fn(); } var args = Array.prototype.slice.call(arguments, 0); var obj = args.pop(); if (!_isArray$2(obj)) { var idx = 0; while (idx < methodNames.length) { if (typeof obj[methodNames[idx]] === 'function') { return obj[methodNames[idx]].apply(obj, args); } idx += 1; } if (_isTransformer(obj)) { var transducer = xf.apply(null, args); return transducer(obj); } } return fn.apply(this, arguments); }; } var _dispatchable_1 = _dispatchable$3; function _reduced$1(x) { return x && x['@@transducer/reduced'] ? x : { '@@transducer/value': x, '@@transducer/reduced': true }; } var _reduced_1 = _reduced$1; var _xfBase$3 = { init: function () { return this.xf['@@transducer/init'](); }, result: function (result) { return this.xf['@@transducer/result'](result); } }; var _curry2$n = _curry2_1; var _reduced = _reduced_1; var _xfBase$2 = _xfBase$3; var XTake = /*#__PURE__*/ function () { function XTake(n, xf) { this.xf = xf; this.n = n; this.i = 0; } XTake.prototype['@@transducer/init'] = _xfBase$2.init; XTake.prototype['@@transducer/result'] = _xfBase$2.result; XTake.prototype['@@transducer/step'] = function (result, input) { this.i += 1; var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; }; return XTake; }(); var _xtake$1 = /*#__PURE__*/ _curry2$n(function _xtake(n, xf) { return new XTake(n, xf); }); var _xtake_1 = _xtake$1; var _isArray$1 = _isArray$3; /** * This checks whether a function has a [methodname] function. If it isn't an * array it will execute that function otherwise it will default to the ramda * implementation. * * @private * @param {Function} fn ramda implemtation * @param {String} methodname property to check for a custom implementation * @return {Object} Whatever the return value of the method is. */ function _checkForMethod$2(methodname, fn) { return function () { var length = arguments.length; if (length === 0) { return fn(); } var obj = arguments[length - 1]; return _isArray$1(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); }; } var _checkForMethod_1 = _checkForMethod$2; var _curry1$c = _curry1_1; var _curry2$m = _curry2_1; var _isPlaceholder$1 = _isPlaceholder_1; /** * Optimized internal three-arity curry function. * * @private * @category Function * @param {Function} fn The function to curry. * @return {Function} The curried function. */ function _curry3$5(fn) { return function f3(a, b, c) { switch (arguments.length) { case 0: return f3; case 1: return _isPlaceholder$1(a) ? f3 : _curry2$m(function (_b, _c) { return fn(a, _b, _c); }); case 2: return _isPlaceholder$1(a) && _isPlaceholder$1(b) ? f3 : _isPlaceholder$1(a) ? _curry2$m(function (_a, _c) { return fn(_a, b, _c); }) : _isPlaceholder$1(b) ? _curry2$m(function (_b, _c) { return fn(a, _b, _c); }) : _curry1$c(function (_c) { return fn(a, b, _c); }); default: return _isPlaceholder$1(a) && _isPlaceholder$1(b) && _isPlaceholder$1(c) ? f3 : _isPlaceholder$1(a) && _isPlaceholder$1(b) ? _curry2$m(function (_a, _b) { return fn(_a, _b, c); }) : _isPlaceholder$1(a) && _isPlaceholder$1(c) ? _curry2$m(function (_a, _c) { return fn(_a, b, _c); }) : _isPlaceholder$1(b) && _isPlaceholder$1(c) ? _curry2$m(function (_b, _c) { return fn(a, _b, _c); }) : _isPlaceholder$1(a) ? _curry1$c(function (_a) { return fn(_a, b, c); }) : _isPlaceholder$1(b) ? _curry1$c(function (_b) { return fn(a, _b, c); }) : _isPlaceholder$1(c) ? _curry1$c(function (_c) { return fn(a, b, _c); }) : fn(a, b, c); } }; } var _curry3_1 = _curry3$5; var _checkForMethod$1 = _checkForMethod_1; var _curry3$4 = _curry3_1; /** * Returns the elements of the given list or string (or object with a `slice` * method) from `fromIndex` (inclusive) to `toIndex` (exclusive). * * Dispatches to the `slice` method of the third argument, if present. * * @func * @memberOf R * @since v0.1.4 * @category List * @sig Number -> Number -> [a] -> [a] * @sig Number -> Number -> String -> String * @param {Number} fromIndex The start index (inclusive). * @param {Number} toIndex The end index (exclusive). * @param {*} list * @return {*} * @example * * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd'] * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c'] * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] * R.slice(0, 3, 'ramda'); //=> 'ram' */ var slice$2 = /*#__PURE__*/ _curry3$4( /*#__PURE__*/ _checkForMethod$1('slice', function slice(fromIndex, toIndex, list) { return Array.prototype.slice.call(list, fromIndex, toIndex); })); var slice_1 = slice$2; var _curry2$l = _curry2_1; var _dispatchable$2 = _dispatchable_1; var _xtake = _xtake_1; var slice$1 = slice_1; /** * Returns the first `n` elements of the given list, string, or * transducer/transformer (or object with a `take` method). * * Dispatches to the `take` method of the second argument, if present. * * @func * @memberOf R * @since v0.1.0 * @category List * @sig Number -> [a] -> [a] * @sig Number -> String -> String * @param {Number} n * @param {*} list * @return {*} * @see R.drop * @example * * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo'] * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] * R.take(3, 'ramda'); //=> 'ram' * * const personnel = [ * 'Dave Brubeck', * 'Paul Desmond', * 'Eugene Wright', * 'Joe Morello', * 'Gerry Mulligan', * 'Bob Bates', * 'Joe Dodge', * 'Ron Crotty' * ]; * * const takeFive = R.take(5); * takeFive(personnel); * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan'] * @symb R.take(-1, [a, b]) = [a, b] * @symb R.take(0, [a, b]) = [] * @symb R.take(1, [a, b]) = [a] * @symb R.take(2, [a, b]) = [a, b] */ var take$1 = /*#__PURE__*/ _curry2$l( /*#__PURE__*/ _dispatchable$2(['take'], _xtake, function take(n, xs) { return slice$1(0, n < 0 ? Infinity : n, xs); })); var take_1 = take$1; var take = take_1; function dropLast$2(n, xs) { return take(n < xs.length ? xs.length - n : 0, xs); } var _dropLast$1 = dropLast$2; var _curry2$k = _curry2_1; var _xfBase$1 = _xfBase$3; var XDropLast = /*#__PURE__*/ function () { function XDropLast(n, xf) { this.xf = xf; this.pos = 0; this.full = false; this.acc = new Array(n); } XDropLast.prototype['@@transducer/init'] = _xfBase$1.init; XDropLast.prototype['@@transducer/result'] = function (result) { this.acc = null; return this.xf['@@transducer/result'](result); }; XDropLast.prototype['@@transducer/step'] = function (result, input) { if (this.full) { result = this.xf['@@transducer/step'](result, this.acc[this.pos]); } this.store(input); return result; }; XDropLast.prototype.store = function (input) { this.acc[this.pos] = input; this.pos += 1; if (this.pos === this.acc.length) { this.pos = 0; this.full = true; } }; return XDropLast; }(); var _xdropLast$1 = /*#__PURE__*/ _curry2$k(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); var _xdropLast_1 = _xdropLast$1; var _curry2$j = _curry2_1; var _dispatchable$1 = _dispatchable_1; var _dropLast = _dropLast$1; var _xdropLast = _xdropLast_1; /** * Returns a list containing all but the last `n` elements of the given `list`. * * Acts as a transducer if a transformer is given in list position. * * @func * @memberOf R * @since v0.16.0 * @category List * @sig Number -> [a] -> [a] * @sig Number -> String -> String * @param {Number} n The number of elements of `list` to skip. * @param {Array} list The list of elements to consider. * @return {Array} A copy of the list with only the first `list.length - n` elements * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile * @example * * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo'] * R.dropLast(3, ['foo', 'bar', 'baz']); //=> [] * R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] * R.dropLast(3, 'ramda'); //=> 'ra' */ var dropLast = /*#__PURE__*/ _curry2$j( /*#__PURE__*/ _dispatchable$1([], _xdropLast, _dropLast)); var dropLast_1 = dropLast; var dropLast$1 = dropLast_1; function _map$1(fn, functor) { var idx = 0; var len = functor.length; var result = Array(len); while (idx < len) { result[idx] = fn(functor[idx]); idx += 1; } return result; } var _map_1 = _map$1; function _isString$3(x) { return Object.prototype.toString.call(x) === '[object String]'; } var _isString_1 = _isString$3; var _curry1$b = _curry1_1; var _isArray = _isArray$3; var _isString$2 = _isString_1; /** * Tests whether or not an object is similar to an array. * * @private * @category Type * @category List * @sig * -> Boolean * @param {*} x The object to test. * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise. * @example * * _isArrayLike([]); //=> true * _isArrayLike(true); //=> false * _isArrayLike({}); //=> false * _isArrayLike({length: 10}); //=> false * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true */ var _isArrayLike$1 = /*#__PURE__*/ _curry1$b(function isArrayLike(x) { if (_isArray(x)) { return true; } if (!x) { return false; } if (typeof x !== 'object') { return false; } if (_isString$2(x)) { return false; } if (x.nodeType === 1) { return !!x.length; } if (x.length === 0) { return true; } if (x.length > 0) { return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); } return false; }); var _isArrayLike_1 = _isArrayLike$1; var XWrap = /*#__PURE__*/ function () { function XWrap(fn) { this.f = fn; } XWrap.prototype['@@transducer/init'] = function () { throw new Error('init not implemented on XWrap'); }; XWrap.prototype['@@transducer/result'] = function (acc) { return acc; }; XWrap.prototype['@@transducer/step'] = function (acc, x) { return this.f(acc, x); }; return XWrap; }(); function _xwrap$1(fn) { return new XWrap(fn); } var _xwrap_1 = _xwrap$1; function _arity$5(n, fn) { /* eslint-disable no-unused-vars */ switch (n) { case 0: return function () { return fn.apply(this, arguments); }; case 1: return function (a0) { return fn.apply(this, arguments); }; case 2: return function (a0, a1) { return fn.apply(this, arguments); }; case 3: return function (a0, a1, a2) { return fn.apply(this, arguments); }; case 4: return function (a0, a1, a2, a3) { return fn.apply(this, arguments); }; case 5: return function (a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; case 6: return function (a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; case 7: return function (a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; case 8: return function (a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; case 9: return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; case 10: return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); } } var _arity_1 = _arity$5; var _arity$4 = _arity_1; var _curry2$i = _curry2_1; /** * Creates a function that is bound to a context. * Note: `R.bind` does not provide the additional argument-binding capabilities of * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). * * @func * @memberOf R * @since v0.6.0 * @category Function * @category Object * @sig (* -> *) -> {*} -> (* -> *) * @param {Function} fn The function to bind to context * @param {Object} thisObj The context to bind `fn` to * @return {Function} A function that will execute in the context of `thisObj`. * @see R.partial * @example * * const log = R.bind(console.log, console); * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3} * // logs {a: 2} * @symb R.bind(f, o)(a, b) = f.call(o, a, b) */ var bind$1 = /*#__PURE__*/ _curry2$i(function bind(fn, thisObj) { return _arity$4(fn.length, function () { return fn.apply(thisObj, arguments); }); }); var bind_1 = bind$1; var _isArrayLike = _isArrayLike_1; var _xwrap = _xwrap_1; var bind = bind_1; function _arrayReduce(xf, acc, list) { var idx = 0; var len = list.length; while (idx < len) { acc = xf['@@transducer/step'](acc, list[idx]); if (acc && acc['@@transducer/reduced']) { acc = acc['@@transducer/value']; break; } idx += 1; } return xf['@@transducer/result'](acc); } function _iterableReduce(xf, acc, iter) { var step = iter.next(); while (!step.done) { acc = xf['@@transducer/step'](acc, step.value); if (acc && acc['@@transducer/reduced']) { acc = acc['@@transducer/value']; break; } step = iter.next(); } return xf['@@transducer/result'](acc); } function _methodReduce(xf, acc, obj, methodName) { return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); } var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator'; function _reduce$3(fn, acc, list) { if (typeof fn === 'function') { fn = _xwrap(fn); } if (_isArrayLike(list)) { return _arrayReduce(fn, acc, list); } if (typeof list['fantasy-land/reduce'] === 'function') { return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); } if (list[symIterator] != null) { return _iterableReduce(fn, acc, list[symIterator]()); } if (typeof list.next === 'function') { return _iterableReduce(fn, acc, list); } if (typeof list.reduce === 'function') { return _methodReduce(fn, acc, list, 'reduce'); } throw new TypeError('reduce: list must be array or iterable'); } var _reduce_1 = _reduce$3; var _curry2$h = _curry2_1; var _xfBase = _xfBase$3; var XMap = /*#__PURE__*/ function () { function XMap(f, xf) { this.xf = xf; this.f = f; } XMap.prototype['@@transducer/init'] = _xfBase.init; XMap.prototype['@@transducer/result'] = _xfBase.result; XMap.prototype['@@transducer/step'] = function (result, input) { return this.xf['@@transducer/step'](result, this.f(input)); }; return XMap; }(); var _xmap$1 = /*#__PURE__*/ _curry2$h(function _xmap(f, xf) { return new XMap(f, xf); }); var _xmap_1 = _xmap$1; var _arity$3 = _arity_1; var _isPlaceholder = _isPlaceholder_1; /** * Internal curryN function. * * @private * @category Function * @param {Number} length The arity of the curried function. * @param {Array} received An array of arguments received thus far. * @param {Function} fn The function to curry. * @return {Function} The curried function. */ function _curryN$1(length, received, fn) { return function () { var combined = []; var argsIdx = 0; var left = length; var combinedIdx = 0; while (combinedIdx < received.length || argsIdx < arguments.length) { var result; if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) { result = received[combinedIdx]; } else { result = arguments[argsIdx]; argsIdx += 1; } combined[combinedIdx] = result; if (!_isPlaceholder(result)) { left -= 1; } combinedIdx += 1; } return left <= 0 ? fn.apply(this, combined) : _arity$3(left, _curryN$1(length, combined, fn)); }; } var _curryN_1 = _curryN$1; var _arity$2 = _arity_1; var _curry1$a = _curry1_1; var _curry2$g = _curry2_1; var _curryN = _curryN_1; /** * Returns a curried equivalent of the provided function, with the specified * arity. The curried function has two unusual capabilities. First, its * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the * following are equivalent: * * - `g(1)(2)(3)` * - `g(1)(2, 3)` * - `g(1, 2)(3)` * - `g(1, 2, 3)` * * Secondly, the special placeholder value [`R.__`](#__) may be used to specify * "gaps", allowing partial application of any combination of arguments, * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), * the following are equivalent: * * - `g(1, 2, 3)` * - `g(_, 2, 3)(1)` * - `g(_, _, 3)(1)(2)` * - `g(_, _, 3)(1, 2)` * - `g(_, 2)(1)(3)` * - `g(_, 2)(1, 3)` * - `g(_, 2)(_, 3)(1)` * * @func * @memberOf R * @since v0.5.0 * @category Function * @sig Number -> (* -> a) -> (* -> a) * @param {Number} length The arity for the returned function. * @param {Function} fn The function to curry. * @return {Function} A new, curried function. * @see R.curry * @example * * const sumArgs = (...args) => R.sum(args); * * const curriedAddFourNumbers = R.curryN(4, sumArgs); * const f = curriedAddFourNumbers(1, 2); * const g = f(3); * g(4); //=> 10 */ var curryN$4 = /*#__PURE__*/ _curry2$g(function curryN(length, fn) { if (length === 1) { return _curry1$a(fn); } return _arity$2(length, _curryN(length, [], fn)); }); var curryN_1 = curryN$4; function _has$5(prop, obj) { return Object.prototype.hasOwnProperty.call(obj, prop); } var _has_1 = _has$5; var _has$4 = _has_1; var toString = Object.prototype.toString; var _isArguments$1 = /*#__PURE__*/ function () { return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } : function _isArguments(x) { return _has$4('callee', x); }; }(); var _isArguments_1 = _isArguments$1; var _curry1$9 = _curry1_1; var _has$3 = _has_1; var _isArguments = _isArguments_1; // cover IE < 9 keys issues var hasEnumBug = ! /*#__PURE__*/ { toString: null }.propertyIsEnumerable('toString'); var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug var hasArgsEnumBug = /*#__PURE__*/ function () { return arguments.propertyIsEnumerable('length'); }(); var contains = function contains(list, item) { var idx = 0; while (idx < list.length) { if (list[idx] === item) { return true; } idx += 1; } return false; }; /** * Returns a list containing the names of all the enumerable own properties of * the supplied object. * Note that the order of the output array is not guaranteed to be consistent * across different JS platforms. * * @func * @memberOf R * @since v0.1.0 * @category Object * @sig {k: v} -> [k] * @param {Object} obj The object to extract properties from * @return {Array} An array of the object's own properties. * @see R.keysIn, R.values * @example * * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] */ var keys$3 = typeof Object.keys === 'function' && !hasArgsEnumBug ? /*#__PURE__*/ _curry1$9(function keys(obj) { return Object(obj) !== obj ? [] : Object.keys(obj); }) : /*#__PURE__*/ _curry1$9(function keys(obj) { if (Object(obj) !== obj) { return []; } var prop, nIdx; var ks = []; var checkArgsLength = hasArgsEnumBug && _isArguments(obj); for (prop in obj) { if (_has$3(prop, obj) && (!checkArgsLength || prop !== 'length')) { ks[ks.length] = prop; } } if (hasEnumBug) { nIdx = nonEnumerableProps.length - 1; while (nIdx >= 0) { prop = nonEnumerableProps[nIdx]; if (_has$3(prop, obj) && !contains(ks, prop)) { ks[ks.length] = prop; } nIdx -= 1; } } return ks; }); var keys_1 = keys$3; var _curry2$f = _curry2_1; var _dispatchable = _dispatchable_1; var _map = _map_1; var _reduce$2 = _reduce_1; var _xmap = _xmap_1; var curryN$3 = curryN_1; var keys$2 = keys_1; /** * Takes a function and * a [functor](https://github.com/fantasyland/fantasy-land#functor), * applies the function to each of the functor's values, and returns * a functor of the same shape. * * Ramda provides suitable `map` implementations for `Array` and `Object`, * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`. * * Dispatches to the `map` method of the second argument, if present. * * Acts as a transducer if a transformer is given in list position. * * Also treats functions as functors and will compose them together. * * @func * @memberOf R * @since v0.1.0 * @category List * @sig Functor f => (a -> b) -> f a -> f b * @param {Function} fn The function to be called on every element of the input `list`. * @param {Array} list The list to be iterated over. * @return {Array} The new list. * @see R.transduce, R.addIndex * @example * * const double = x => x * 2; * * R.map(double, [1, 2, 3]); //=> [2, 4, 6] * * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6} * @symb R.map(f, [a, b]) = [f(a), f(b)] * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } * @symb R.map(f, functor_o) = functor_o.map(f) */ var map$2 = /*#__PURE__*/ _curry2$f( /*#__PURE__*/ _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { switch (Object.prototype.toString.call(functor)) { case '[object Function]': return curryN$3(functor.length, function () { return fn.call(this, functor.apply(this, arguments)); }); case '[object Object]': return _reduce$2(function (acc, key) { acc[key] = fn(functor[key]); return acc; }, {}, keys$2(functor)); default: return _map(fn, functor); } })); var map_1 = map$2; var map$3 = map_1; // Unique ID creation requires a high quality random # generator. In the browser we therefore // require the crypto API and do not support built-in fallback to lower quality random number // generators (like Math.random()). var getRandomValues; var rnds8 = new Uint8Array(16); function rng() { // lazy load so that environments that need to polyfill have a chance to do so if (!getRandomValues) { // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, // find the complete implementation of crypto (msCrypto) on IE11. getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); if (!getRandomValues) { throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); } } return getRandomValues(rnds8); } var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; function validate(uuid) { return typeof uuid === 'string' && REGEX.test(uuid); } /** * Convert array of 16 byte values to UUID string format of the form: * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */ var byteToHex = []; for (var i = 0; i < 256; ++i) { byteToHex.push((i + 0x100).toString(16).substr(1)); } function stringify(arr) { var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; // Note: Be careful editing this code! It's been tuned for performance // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one // of the following: // - One or more input array values don't map to a hex octet (leading to // "undefined" in the uuid) // - Invalid input values for the RFC `version` or `variant` fields if (!validate(uuid)) { throw TypeError('Stringified UUID is invalid'); } return uuid; } function v4(options, buf, offset) { options = options || {}; var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` rnds[6] = rnds[6] & 0x0f | 0x40; rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided if (buf) { offset = offset || 0; for (var i = 0; i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return stringify(rnds); } /** * Private `concat` function to merge two array-like objects. * * @private * @param {Array|Arguments} [set1=[]] An array-like object. * @param {Array|Arguments} [set2=[]] An array-like object. * @return {Array} A new, merged array. * @example * * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] */ function _concat$2(set1, set2) { set1 = set1 || []; set2 = set2 || []; var idx; var len1 = set1.length; var len2 = set2.length; var result = []; idx = 0; while (idx < len1) { result[result.length] = set1[idx]; idx += 1; } idx = 0; while (idx < len2) { result[result.length] = set2[idx]; idx += 1; } return result; } var _concat_1 = _concat$2; var _concat$1 = _concat_1; var _curry1$8 = _curry1_1; var curryN$2 = curryN_1; /** * Creates a new list iteration function from an existing one by adding two new * parameters to its callback function: the current index, and the entire list. * * This would turn, for instance, [`R.map`](#map) function into one that * more closely resembles `Array.prototype.map`. Note that this will only work * for functions in which the iteration callback function is the first * parameter, and where the list is the last parameter. (This latter might be * unimportant if the list parameter is not used.) * * @func * @memberOf R * @since v0.15.0 * @category Function * @category List * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *) * @param {Function} fn A list iteration function that does not pass index or list to its callback * @return {Function} An altered list iteration function that passes (item, index, list) to its callback * @example * * const mapIndexed = R.addIndex(R.map); * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']); * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] */ var addIndex = /*#__PURE__*/ _curry1$8(function addIndex(fn) { return curryN$2(fn.length, function () { var idx = 0; var origFn = arguments[0]; var list = arguments[arguments.length - 1]; var args = Array.prototype.slice.call(arguments, 0); args[0] = function () { var result = origFn.apply(this, _concat$1(arguments, [idx, list])); idx += 1; return result; }; return fn.apply(this, args); }); }); var addIndex_1 = addIndex; var addIndex$1 = addIndex_1; var _curry2$e = _curry2_1; /** * Creates a new object by recursively evolving a shallow copy of `object`, * according to the `transformation` functions. All non-primitive properties * are copied by reference. * * A `transformation` function will not be invoked if its corresponding key * does not exist in the evolved object. * * @func * @memberOf R * @since v0.9.0 * @category Object * @sig {k: (v -> v)} -> {k: v} -> {k: v} * @param {Object} transformations The object specifying transformation functions to apply * to the object. * @param {Object} object The object to be transformed. * @return {Object} The transformed object. * @example * * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123}; * const transformations = { * firstName: R.trim, * lastName: R.trim, // Will not get invoked. * data: {elapsed: R.add(1), remaining: R.add(-1)} * }; * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} */ var evolve = /*#__PURE__*/ _curry2$e(function evolve(transformations, object) { var result = object instanceof Array ? [] : {}; var transformation, key, type; for (key in object) { transformation = transformations[key]; type = typeof transformation; result[key] = type === 'function' ? transformation(object[key]) : transformation && type === 'object' ? evolve(transformation, object[key]) : object[key]; } return result; }); var evolve_1 = evolve; var evolve$1 = evolve_1; function _identity$1(x) { return x; } var _identity_1 = _identity$1; var _curry1$7 = _curry1_1; var _identity = _identity_1; /** * A function that does nothing but return the parameter supplied to it. Good * as a default or placeholder function. * * @func * @memberOf R * @since v0.1.0 * @category Function * @sig a -> a * @param {*} x The value to return. * @return {*} The input value, `x`. * @example * * R.identity(1); //=> 1 * * const obj = {}; * R.identity(obj) === obj; //=> true * @symb R.identity(a) = a */ var identity = /*#__PURE__*/ _curry1$7(_identity); var identity_1 = identity; var identity$1 = identity_1; var _curry2$d = _curry2_1; var _reduce$1 = _reduce_1; var keys$1 = keys_1; /** * An Object-specific version of [`map`](#map). The function is applied to three * arguments: *(value, key, obj)*. If only the value is significant, use * [`map`](#map) instead. * * @func * @memberOf R * @since v0.9.0 * @category Object * @sig ((*, String, Object) -> *) -> Object -> Object * @param {Function} fn * @param {Object} obj * @return {Object} * @see R.map * @example * * const xyz = { x: 1, y: 2, z: 3 }; * const prependKeyAndDouble = (num, key, obj) => key + (num * 2); * * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' } */ var mapObjIndexed = /*#__PURE__*/ _curry2$d(function mapObjIndexed(fn, obj) { return _reduce$1(function (acc, key) { acc[key] = fn(obj[key], key, obj); return acc; }, {}, keys$1(obj)); }); var mapObjIndexed_1 = mapObjIndexed; var mapObjIndexed$1 = mapObjIndexed_1; /** * Determine if the passed argument is an integer. * * @private * @param {*} n * @category Type * @return {Boolean} */ var _isInteger$1 = Number.isInteger || function _isInteger(n) { return n << 0 === n; }; var _curry2$c = _curry2_1; var _isString$1 = _isString_1; /** * Returns the nth element of the given list or string. If n is negative the * element at index length + n is returned. * * @func * @memberOf R * @since v0.1.0 * @category List * @sig Number -> [a] -> a | Undefined * @sig Number -> String -> String * @param {Number} offset * @param {*} list * @return {*} * @example * * const list = ['foo', 'bar', 'baz', 'quux']; * R.nth(1, list); //=> 'bar' * R.nth(-1, list); //=> 'quux' * R.nth(-99, list); //=> undefined * * R.nth(2, 'abc'); //=> 'c' * R.nth(3, 'abc'); //=> '' * @symb R.nth(-1, [a, b, c]) = c * @symb R.nth(0, [a, b, c]) = a * @symb R.nth(1, [a, b, c]) = b */ var nth$1 = /*#__PURE__*/ _curry2$c(function nth(offset, list) { var idx = offset < 0 ? list.length + offset : offset; return _isString$1(list) ? list.charAt(idx) : list[idx]; }); var nth_1 = nth$1; var _curry2$b = _curry2_1; var _isInteger = _isInteger$1; var nth = nth_1; /** * Retrieves the values at given paths of an object. * * @func * @memberOf R * @since v0.27.1 * @category Object * @typedefn Idx = [String | Int] * @sig [Idx] -> {a} -> [a | Undefined] * @param {Array} pathsArray The array of paths to be fetched. * @param {Object} obj The object to retrieve the nested properties from. * @return {Array} A list consisting of values at paths specified by "pathsArray". * @see R.path * @example * * R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3] * R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined] */ var paths$1 = /*#__PURE__*/ _curry2$b(function paths(pathsArray, obj) { return pathsArray.map(function (paths) { var val = obj; var idx = 0; var p; while (idx < paths.length) { if (val == null) { return; } p = paths[idx]; val = _isInteger(p) ? nth(p, val) : val[p]; idx += 1; } return val; }); }); var paths_1 = paths$1; var _curry2$a = _curry2_1; var paths = paths_1; /** * Retrieve the value at a given path. * * @func * @memberOf R * @since v0.2.0 * @category Object * @typedefn Idx = String | Int * @sig [Idx] -> {a} -> a | Undefined * @param {Array} path The path to use. * @param {Object} obj The object to retrieve the nested property from. * @return {*} The data at `path`. * @see R.prop, R.nth * @example * * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined * R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1 * R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2 */ var path$1 = /*#__PURE__*/ _curry2$a(function path(pathAr, obj) { return paths([pathAr], obj)[0]; }); var path_1 = path$1; var rPath = path_1; const URIre = /^(http[s]?:\/\/)?([^/\s:#]+)?(:[0-9]+)?((?:\/?\w?)+(?:\/?[\w\-.]+[^#?\s])?)?(\??[^#?\s]+)?(#(?:\/?[\w\-$])*)?$/; /** * @typedef {Object} UriComponents * @prop {?string} match - The full URI that matched the query. * @prop {?string} scheme - The protocol, either "http://" or "https://". * @prop {?string} domain - The domain and/or subdomain (eg, "api.example.com"). * @prop {?string} port - The port if specified (eg, ":80"). * @prop {?string} path - The relative directory path and/or file name (eg, "/foo/index.html"). * @prop {?string} query - Search params (eg, "?foo=42&bar=36"). * @prop {?string} fragment - The hash or JSON pointer (eg, "#Introduction", "#$defs/address"). */ /** * Parses a URI into its component strings. * @param {string} uri * @returns {UriComponents} */ function parseURI(uri) { const groups = uri.match(URIre) || []; const [ match, scheme, domain, port, path, query, fragment, ] = groups; return { match, scheme, domain, port, path, query, fragment, }; } var _curry2$9 = _curry2_1; /** * Returns the larger of its two arguments. * * @func * @memberOf R * @since v0.1.0 * @category Relation * @sig Ord a => a -> a -> a * @param {*} a * @param {*} b * @return {*} * @see R.maxBy, R.min * @example * * R.max(789, 123); //=> 789 * R.max('a', 'b'); //=> 'b' */ var max$2 = /*#__PURE__*/ _curry2$9(function max(a, b) { return b > a ? b : a; }); var max_1 = max$2; var _curry2$8 = _curry2_1; var path = path_1; /** * Returns a function that when supplied an object returns the indicated * property of that object, if it exists. * * @func * @memberOf R * @since v0.1.0 * @category Object * @typedefn Idx = String | Int * @sig Idx -> {s: a} -> a | Undefined * @param {String|Number} p The property name or array index * @param {Object} obj The object to query * @return {*} The value at `obj.p`. * @see R.path, R.nth * @example * * R.prop('x', {x: 100}); //=> 100 * R.prop('x', {}); //=> undefined * R.prop(0, [100]); //=> 100 * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4 */ var prop$1 = /*#__PURE__*/ _curry2$8(function prop(p, obj) { return path([p], obj); }); var prop_1 = prop$1; var prop$2 = prop_1; var _curry2$7 = _curry2_1; var map$1 = map_1; var prop = prop_1; /** * Returns a new list by plucking the same named property off all objects in * the list supplied. * * `pluck` will work on * any [functor](https://github.com/fantasyland/fantasy-land#functor) in * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`. * * @func * @memberOf R * @since v0.1.0 * @category List * @sig Functor f => k -> f {k: v} -> f v * @param {Number|String} key The key name to pluck off of each object. * @param {Array} f The array or functor to consider. * @return {Array} The list of values for the given key. * @see R.props * @example * * var getAges = R.pluck('age'); * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27] * * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3] * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5} * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] */ var pluck$1 = /*#__PURE__*/ _curry2$7(function pluck(p, list) { return map$1(prop(p), list); }); var pluck_1 = pluck$1; var _curry3$3 = _curry3_1; var _reduce = _reduce_1; /** * Returns a single item by iterating through the list, successively calling * the iterator function and passing it an accumulator value and the current * value from the array, and then passing the result to the next call. * * The iterator function receives two values: *(acc, value)*. It may use * [`R.reduced`](#reduced) to shortcut the iteration. * * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function * is *(value, acc)*. * * Note: `R.reduce` does not skip deleted or unassigned indices (sparse * arrays), unlike the native `Array.prototype.reduce` method. For more details * on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description * * Dispatches to the `reduce` method of the third argument, if present. When * doing so, it is up to the user to handle the [`R.reduced`](#reduced) * shortcuting, as this is not implemented by `reduce`. * * @func * @memberOf R * @since v0.1.0 * @category List * @sig ((a, b) -> a) -> a -> [b] -> a * @param {Function} fn The iterator function. Receives two values, the accumulator and the * current element from the array. * @param {*} acc The accumulator value. * @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. * @see R.reduced, R.addIndex, R.reduceRight * @example * * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10 * // - -10 * // / \ / \ * // - 4 -6 4 * // / \ / \ * // - 3 ==> -3 3 * // / \ / \ * // - 2 -1 2 * // / \ / \ * // 0 1 0 1 * * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) */ var reduce$3 = /*#__PURE__*/ _curry3$3(_reduce); var reduce_1 = reduce$3; var reduce$4 = reduce_1; var _curry1$6 = _curry1_