Comparing version 2.1.0 to 2.2.0-beta.0
@@ -5,2 +5,7 @@ # unchanged CHANGELOG | ||
## 2.1.1 | ||
- Fix issue where `getOwnPropertySymbols` was expected to always be supported when `Object.assign` was natively supported | ||
- Greatly improve typings of handlers | ||
## 2.1.0 | ||
@@ -7,0 +12,0 @@ |
@@ -11,11 +11,13 @@ 'use strict'; | ||
var create = O.create, getOwnPropertySymbols = O.getOwnPropertySymbols, getPrototypeOf = O.getPrototypeOf, keys = O.keys, propertyIsEnumerable = O.propertyIsEnumerable; | ||
var toStringObject = O.prototype.toString; | ||
var toStringFunction = Function.prototype.toString; | ||
var isArray = Array.isArray; | ||
var toStringFunction = Function.prototype.bind.call(Function.prototype.call, Function.prototype.toString); | ||
var toStringObject = Function.prototype.bind.call(Function.prototype.call, O.prototype.toString); | ||
/** | ||
* @constant HAS_SYMBOL_SUPPORT are Symbols supported | ||
*/ | ||
var HAS_SYMBOL_SUPPORT = typeof Symbol === 'function' && typeof Symbol.for === 'function'; | ||
/** | ||
* @constant REACT_ELEMENT the symbol / number specific to react elements | ||
*/ | ||
var REACT_ELEMENT = typeof Symbol === 'function' && typeof Symbol.for === 'function' | ||
? Symbol.for('react.element') | ||
: 0xeac7; | ||
var REACT_ELEMENT = HAS_SYMBOL_SUPPORT ? Symbol.for('react.element') : 0xeac7; | ||
/** | ||
@@ -31,5 +33,5 @@ * @function cloneArray | ||
var cloneArray = function (array) { | ||
// @ts-ignore | ||
var cloned = new array.constructor(); | ||
for (var index = 0; index < array.length; index++) { | ||
var Constructor = array.constructor; | ||
var cloned = Constructor === Array ? [] : new Constructor(); | ||
for (var index = 0, length_1 = array.length; index < length_1; index++) { | ||
cloned[index] = array[index]; | ||
@@ -52,3 +54,3 @@ } | ||
var value = initialValue; | ||
for (var index = 0; index < array.length; index++) { | ||
for (var index = 0, length_2 = array.length; index < length_2; index++) { | ||
value = fn(value, array[index]); | ||
@@ -68,2 +70,5 @@ } | ||
var getOwnProperties = function (object) { | ||
if (!HAS_SYMBOL_SUPPORT) { | ||
return keys(object); | ||
} | ||
var ownSymbols = getOwnPropertySymbols(object); | ||
@@ -109,3 +114,5 @@ if (!ownSymbols.length) { | ||
*/ | ||
var createWithProto = function (object) { return create(object.__proto__ || getPrototypeOf(object)); }; | ||
var createWithProto = function (object) { | ||
return create(object.__proto__ || getPrototypeOf(object)); | ||
}; | ||
/** | ||
@@ -121,8 +128,6 @@ * @function isCloneable | ||
var isCloneable = function (object) { | ||
if (!object || | ||
typeof object !== 'object' || | ||
object.$$typeof === REACT_ELEMENT) { | ||
if (!object || typeof object !== 'object' || object.$$typeof === REACT_ELEMENT) { | ||
return false; | ||
} | ||
var type = toStringObject.call(object); | ||
var type = toStringObject(object); | ||
return type !== '[object Date]' && type !== '[object RegExp]'; | ||
@@ -139,5 +144,3 @@ }; | ||
*/ | ||
var isEmptyPath = function (path) { | ||
return path == null || (isArray(path) && !path.length); | ||
}; | ||
var isEmptyPath = function (path) { return path == null || (isArray(path) && !path.length); }; | ||
/** | ||
@@ -153,4 +156,3 @@ * @function isGlobalConstructor | ||
var isGlobalConstructor = function (fn) { | ||
return typeof fn === 'function' && | ||
!!~toStringFunction.call(fn).indexOf('[native code]'); | ||
return typeof fn === 'function' && !!~toStringFunction(fn).indexOf('[native code]'); | ||
}; | ||
@@ -192,3 +194,5 @@ /** | ||
*/ | ||
var getNewEmptyObject = function (object) { return (isArray(object) ? [] : {}); }; | ||
var getNewEmptyObject = function (object) { | ||
return isArray(object) ? [] : {}; | ||
}; | ||
/** | ||
@@ -210,5 +214,3 @@ * @function getShallowClone | ||
} | ||
return isGlobalConstructor(object.constructor) | ||
? {} | ||
: assign(createWithProto(object), object); | ||
return isGlobalConstructor(object.constructor) ? {} : assign(createWithProto(object), object); | ||
}; | ||
@@ -264,3 +266,5 @@ /** | ||
*/ | ||
var getCoalescedValue = function (value, fallbackValue) { return (value === void 0 ? fallbackValue : value); }; | ||
var getCoalescedValue = function (value, fallbackValue) { | ||
return value === void 0 ? fallbackValue : value; | ||
}; | ||
/** | ||
@@ -275,3 +279,5 @@ * @function getParsedPath | ||
*/ | ||
var getParsedPath = function (path) { return (isArray(path) ? path : pathington.parse(path)); }; | ||
var getParsedPath = function (path) { | ||
return isArray(path) ? path : pathington.parse(path); | ||
}; | ||
/** | ||
@@ -365,5 +371,3 @@ * @function getCloneAtPath | ||
if (parsedPath.length === 1) { | ||
return object | ||
? getCoalescedValue(object[parsedPath[0]], noMatchValue) | ||
: noMatchValue; | ||
return object ? getCoalescedValue(object[parsedPath[0]], noMatchValue) : noMatchValue; | ||
} | ||
@@ -416,9 +420,9 @@ var ref = object; | ||
if (array.length) { | ||
var length_1 = array.length; | ||
var cutoff = array.length - 1; | ||
var index = splicedIndex; | ||
while (index < length_1 - 1) { | ||
while (index < cutoff) { | ||
array[index] = array[index + 1]; | ||
++index; | ||
} | ||
--array.length; | ||
array.length = cutoff; | ||
} | ||
@@ -440,15 +444,6 @@ }; | ||
var isArray$1 = Array.isArray; | ||
var slice = Array.prototype.slice; | ||
/** | ||
* @function createCall | ||
* | ||
* @description | ||
* create handlers for call / callWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns call / callWith | ||
*/ | ||
var createCall = function (isWithHandler) { | ||
var slice = Function.prototype.bind.call(Function.prototype.bind, Array.prototype.slice); | ||
function createCall(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, parameters, object, context) { | ||
return function callWith(fn, path, parameters, object, context) { | ||
if (context === void 0) { context = object; } | ||
@@ -458,3 +453,3 @@ if (typeof fn !== 'function') { | ||
} | ||
var extraArgs = slice.call(arguments, 5); | ||
var extraArgs = slice(arguments, 5); | ||
if (isEmptyPath(path)) { | ||
@@ -471,26 +466,15 @@ return callIfFunction(fn.apply(void 0, [object].concat(extraArgs)), context, parameters); | ||
} | ||
return function (path, parameters, object, context) { | ||
return function call(path, parameters, object, context) { | ||
if (context === void 0) { context = object; } | ||
var callable = isEmptyPath(path) | ||
? object | ||
: getValueAtPath(path, object); | ||
var callable = isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
return callIfFunction(callable, context, parameters); | ||
}; | ||
}; | ||
/** | ||
* @function createGet | ||
* | ||
* @description | ||
* create handlers for get / getWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns get / getWith | ||
*/ | ||
var createGet = function (isWithHandler) { | ||
} | ||
function createGet(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function getWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -503,22 +487,13 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (path, object) { | ||
return function get(path, object) { | ||
return isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
}; | ||
}; | ||
/** | ||
* @function createGetOr | ||
* | ||
* @description | ||
* create handlers for getOr / getWithOr | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns getOr / getWithOr | ||
*/ | ||
var createGetOr = function (isWithHandler) { | ||
} | ||
function createGetOr(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, noMatchValue, path, object) { | ||
return function getWithOr(fn, noMatchValue, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -531,22 +506,13 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (noMatchValue, path, object) { | ||
return function getOr(noMatchValue, path, object) { | ||
return isEmptyPath(path) ? object : getValueAtPath(path, object, noMatchValue); | ||
}; | ||
}; | ||
/** | ||
* @function createHas | ||
* | ||
* @description | ||
* create handlers for has / hasWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns has / hasWith | ||
*/ | ||
var createHas = function (isWithHandler) { | ||
} | ||
function createHas(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function hasWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (isEmptyPath(path)) { | ||
@@ -559,24 +525,13 @@ return !!fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (path, object) { | ||
return isEmptyPath(path) | ||
? object != null | ||
: getValueAtPath(path, object) !== void 0; | ||
return function has(path, object) { | ||
return isEmptyPath(path) ? object != null : getValueAtPath(path, object) !== void 0; | ||
}; | ||
}; | ||
/** | ||
* @function createIs | ||
* | ||
* @description | ||
* create handlers for is / isWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns is / isWith | ||
*/ | ||
var createIs = function (isWithHandler) { | ||
} | ||
function createIs(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, value, object) { | ||
return function isWith(fn, path, value, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -588,25 +543,14 @@ return isSameValueZero(fn.apply(void 0, [object].concat(extraArgs)), value); | ||
} | ||
return function (path, value, object) { | ||
return isEmptyPath(path) | ||
? isSameValueZero(object, value) | ||
: isSameValueZero(getValueAtPath(path, object), value); | ||
return function is(path, value, object) { | ||
var _path = isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
return isSameValueZero(_path, value); | ||
}; | ||
}; | ||
/** | ||
* @function createMerge | ||
* | ||
* @description | ||
* create handlers for merge / mergeWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @param isDeep is the handler for a deep merge or shallow | ||
* @returns merge / mergeWith | ||
*/ | ||
var createMerge = function (isWithHandler, isDeep) { | ||
} | ||
function createMerge(isWithHandler, isDeep) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function mergeWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (!isCloneable(object)) { | ||
@@ -617,5 +561,3 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
var objectToMerge = fn.apply(void 0, [object].concat(extraArgs)); | ||
return objectToMerge | ||
? getMergedObject(object, objectToMerge, isDeep) | ||
: object; | ||
return objectToMerge ? getMergedObject(object, objectToMerge, isDeep) : object; | ||
} | ||
@@ -633,3 +575,3 @@ var hasChanged = false; | ||
} | ||
return function (path, objectToMerge, object) { | ||
return function merge(path, objectToMerge, object) { | ||
if (!isCloneable(object)) { | ||
@@ -644,34 +586,16 @@ return objectToMerge; | ||
}; | ||
}; | ||
/** | ||
* @function createNot | ||
* | ||
* @description | ||
* create handlers for not / notWith | ||
* | ||
* @param isWithHandler not the method using a with handler | ||
* @returns not / notWithHandler | ||
*/ | ||
var createNot = function (isWithHandler) { | ||
} | ||
function createNot(isWithHandler) { | ||
var is = createIs(isWithHandler); | ||
return function () { | ||
return function not() { | ||
return !is.apply(this, arguments); | ||
}; | ||
}; | ||
/** | ||
* @function createRemove | ||
* | ||
* @description | ||
* create handlers for remove / removeWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns remove / removeWith | ||
*/ | ||
var createRemove = function (isWithHandler) { | ||
} | ||
function createRemove(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function removeWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (isEmptyPath(path)) { | ||
@@ -694,3 +618,3 @@ var emptyObject = getNewEmptyObject(object); | ||
} | ||
return function (path, object) { | ||
return function remove(path, object) { | ||
if (isEmptyPath(path)) { | ||
@@ -710,19 +634,10 @@ return getNewEmptyObject(object); | ||
}; | ||
}; | ||
/** | ||
* @function createSet | ||
* | ||
* @description | ||
* create handlers for set / setWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns set / setWith | ||
*/ | ||
var createSet = function (isWithHandler) { | ||
} | ||
function createSet(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function setWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
return isEmptyPath(path) | ||
@@ -734,3 +649,3 @@ ? fn.apply(void 0, [object].concat(extraArgs)) : getDeepClone(path, object, function (ref, key) { | ||
} | ||
return function (path, value, object) { | ||
return function set(path, value, object) { | ||
return isEmptyPath(path) | ||
@@ -742,47 +657,45 @@ ? value | ||
}; | ||
}; | ||
/** | ||
* @function createAdd | ||
* | ||
* @description | ||
* create handlers for add / addWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns add / addWith | ||
*/ | ||
var createAdd = function (isWithHandler) { | ||
var add = createSet(isWithHandler); | ||
} | ||
function createAdd(isWithHandler) { | ||
var _add = createSet(isWithHandler); | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return add.apply(this, [fn, getFullPath(path, object, fn), object].concat(slice.call(arguments, 3))); | ||
return function addWith(fn, path, object) { | ||
return _add.apply(this, [fn, getFullPath(path, object, fn), object].concat(slice(arguments, 3))); | ||
}; | ||
} | ||
return function (path, value, object) { return add(getFullPath(path, object), value, object); }; | ||
}; | ||
return function add(path, value, object) { | ||
return _add(getFullPath(path, object), value, object); | ||
}; | ||
} | ||
// external dependencies | ||
var add = curriable.curry(createAdd(false), 3); | ||
var addWith = curriable.curry(createAdd(true), 3); | ||
var assign$1 = curriable.curry(createMerge(false, false), 3); | ||
var assignWith = curriable.curry(createMerge(true, false), 3); | ||
var add = curriable.curry(createAdd(false)); | ||
var addWith = curriable.curry(createAdd(true)); | ||
var assign$1 = curriable.curry(createMerge(false, false)); | ||
var assignWith = curriable.curry(createMerge(true, false)); | ||
var call = curriable.curry(createCall(false), 3); | ||
var callWith = curriable.curry(createCall(true), 4); | ||
var get = curriable.curry(createGet(false), 2); | ||
var getOr = curriable.curry(createGetOr(false), 3); | ||
var getWith = curriable.curry(createGet(true), 3); | ||
var getWithOr = curriable.curry(createGetOr(true), 4); | ||
var has = curriable.curry(createHas(false), 2); | ||
var hasWith = curriable.curry(createHas(true), 3); | ||
var is = curriable.curry(createIs(false), 3); | ||
var isWith = curriable.curry(createIs(true), 4); | ||
var merge = curriable.curry(createMerge(false, true), 3); | ||
var mergeWith = curriable.curry(createMerge(true, true), 3); | ||
var not = curriable.curry(createNot(false), 3); | ||
var notWith = curriable.curry(createNot(true), 4); | ||
var remove = curriable.curry(createRemove(false), 2); | ||
var removeWith = curriable.curry(createRemove(true), 3); | ||
var set = curriable.curry(createSet(false), 3); | ||
var setWith = curriable.curry(createSet(true), 3); | ||
var get = curriable.curry(createGet(false)); | ||
var getOr = curriable.curry(createGetOr(false)); | ||
var getWith = curriable.curry(createGet(true)); | ||
var getWithOr = curriable.curry(createGetOr(true)); | ||
var has = curriable.curry(createHas(false)); | ||
var hasWith = curriable.curry(createHas(true)); | ||
var is = curriable.curry(createIs(false)); | ||
var isWith = curriable.curry(createIs(true)); | ||
var merge = curriable.curry(createMerge(false, true)); | ||
var mergeWith = curriable.curry(createMerge(true, true)); | ||
var not = curriable.curry(createNot(false)); | ||
var notWith = curriable.curry(createNot(true)); | ||
var remove = curriable.curry(createRemove(false)); | ||
var removeWith = curriable.curry(createRemove(true)); | ||
var set = curriable.curry(createSet(false)); | ||
var setWith = curriable.curry(createSet(true)); | ||
exports.__ = curriable.__; | ||
Object.defineProperty(exports, '__', { | ||
enumerable: true, | ||
get: function () { | ||
return curriable.__; | ||
} | ||
}); | ||
exports.add = add; | ||
@@ -789,0 +702,0 @@ exports.addWith = addWith; |
@@ -8,11 +8,13 @@ import { curry } from 'curriable'; | ||
var create = O.create, getOwnPropertySymbols = O.getOwnPropertySymbols, getPrototypeOf = O.getPrototypeOf, keys = O.keys, propertyIsEnumerable = O.propertyIsEnumerable; | ||
var toStringObject = O.prototype.toString; | ||
var toStringFunction = Function.prototype.toString; | ||
var isArray = Array.isArray; | ||
var toStringFunction = Function.prototype.bind.call(Function.prototype.call, Function.prototype.toString); | ||
var toStringObject = Function.prototype.bind.call(Function.prototype.call, O.prototype.toString); | ||
/** | ||
* @constant HAS_SYMBOL_SUPPORT are Symbols supported | ||
*/ | ||
var HAS_SYMBOL_SUPPORT = typeof Symbol === 'function' && typeof Symbol.for === 'function'; | ||
/** | ||
* @constant REACT_ELEMENT the symbol / number specific to react elements | ||
*/ | ||
var REACT_ELEMENT = typeof Symbol === 'function' && typeof Symbol.for === 'function' | ||
? Symbol.for('react.element') | ||
: 0xeac7; | ||
var REACT_ELEMENT = HAS_SYMBOL_SUPPORT ? Symbol.for('react.element') : 0xeac7; | ||
/** | ||
@@ -28,5 +30,5 @@ * @function cloneArray | ||
var cloneArray = function (array) { | ||
// @ts-ignore | ||
var cloned = new array.constructor(); | ||
for (var index = 0; index < array.length; index++) { | ||
var Constructor = array.constructor; | ||
var cloned = Constructor === Array ? [] : new Constructor(); | ||
for (var index = 0, length_1 = array.length; index < length_1; index++) { | ||
cloned[index] = array[index]; | ||
@@ -49,3 +51,3 @@ } | ||
var value = initialValue; | ||
for (var index = 0; index < array.length; index++) { | ||
for (var index = 0, length_2 = array.length; index < length_2; index++) { | ||
value = fn(value, array[index]); | ||
@@ -65,2 +67,5 @@ } | ||
var getOwnProperties = function (object) { | ||
if (!HAS_SYMBOL_SUPPORT) { | ||
return keys(object); | ||
} | ||
var ownSymbols = getOwnPropertySymbols(object); | ||
@@ -106,3 +111,5 @@ if (!ownSymbols.length) { | ||
*/ | ||
var createWithProto = function (object) { return create(object.__proto__ || getPrototypeOf(object)); }; | ||
var createWithProto = function (object) { | ||
return create(object.__proto__ || getPrototypeOf(object)); | ||
}; | ||
/** | ||
@@ -118,8 +125,6 @@ * @function isCloneable | ||
var isCloneable = function (object) { | ||
if (!object || | ||
typeof object !== 'object' || | ||
object.$$typeof === REACT_ELEMENT) { | ||
if (!object || typeof object !== 'object' || object.$$typeof === REACT_ELEMENT) { | ||
return false; | ||
} | ||
var type = toStringObject.call(object); | ||
var type = toStringObject(object); | ||
return type !== '[object Date]' && type !== '[object RegExp]'; | ||
@@ -136,5 +141,3 @@ }; | ||
*/ | ||
var isEmptyPath = function (path) { | ||
return path == null || (isArray(path) && !path.length); | ||
}; | ||
var isEmptyPath = function (path) { return path == null || (isArray(path) && !path.length); }; | ||
/** | ||
@@ -150,4 +153,3 @@ * @function isGlobalConstructor | ||
var isGlobalConstructor = function (fn) { | ||
return typeof fn === 'function' && | ||
!!~toStringFunction.call(fn).indexOf('[native code]'); | ||
return typeof fn === 'function' && !!~toStringFunction(fn).indexOf('[native code]'); | ||
}; | ||
@@ -189,3 +191,5 @@ /** | ||
*/ | ||
var getNewEmptyObject = function (object) { return (isArray(object) ? [] : {}); }; | ||
var getNewEmptyObject = function (object) { | ||
return isArray(object) ? [] : {}; | ||
}; | ||
/** | ||
@@ -207,5 +211,3 @@ * @function getShallowClone | ||
} | ||
return isGlobalConstructor(object.constructor) | ||
? {} | ||
: assign(createWithProto(object), object); | ||
return isGlobalConstructor(object.constructor) ? {} : assign(createWithProto(object), object); | ||
}; | ||
@@ -261,3 +263,5 @@ /** | ||
*/ | ||
var getCoalescedValue = function (value, fallbackValue) { return (value === void 0 ? fallbackValue : value); }; | ||
var getCoalescedValue = function (value, fallbackValue) { | ||
return value === void 0 ? fallbackValue : value; | ||
}; | ||
/** | ||
@@ -272,3 +276,5 @@ * @function getParsedPath | ||
*/ | ||
var getParsedPath = function (path) { return (isArray(path) ? path : parse(path)); }; | ||
var getParsedPath = function (path) { | ||
return isArray(path) ? path : parse(path); | ||
}; | ||
/** | ||
@@ -362,5 +368,3 @@ * @function getCloneAtPath | ||
if (parsedPath.length === 1) { | ||
return object | ||
? getCoalescedValue(object[parsedPath[0]], noMatchValue) | ||
: noMatchValue; | ||
return object ? getCoalescedValue(object[parsedPath[0]], noMatchValue) : noMatchValue; | ||
} | ||
@@ -413,9 +417,9 @@ var ref = object; | ||
if (array.length) { | ||
var length_1 = array.length; | ||
var cutoff = array.length - 1; | ||
var index = splicedIndex; | ||
while (index < length_1 - 1) { | ||
while (index < cutoff) { | ||
array[index] = array[index + 1]; | ||
++index; | ||
} | ||
--array.length; | ||
array.length = cutoff; | ||
} | ||
@@ -437,15 +441,6 @@ }; | ||
var isArray$1 = Array.isArray; | ||
var slice = Array.prototype.slice; | ||
/** | ||
* @function createCall | ||
* | ||
* @description | ||
* create handlers for call / callWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns call / callWith | ||
*/ | ||
var createCall = function (isWithHandler) { | ||
var slice = Function.prototype.bind.call(Function.prototype.bind, Array.prototype.slice); | ||
function createCall(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, parameters, object, context) { | ||
return function callWith(fn, path, parameters, object, context) { | ||
if (context === void 0) { context = object; } | ||
@@ -455,3 +450,3 @@ if (typeof fn !== 'function') { | ||
} | ||
var extraArgs = slice.call(arguments, 5); | ||
var extraArgs = slice(arguments, 5); | ||
if (isEmptyPath(path)) { | ||
@@ -468,26 +463,15 @@ return callIfFunction(fn.apply(void 0, [object].concat(extraArgs)), context, parameters); | ||
} | ||
return function (path, parameters, object, context) { | ||
return function call(path, parameters, object, context) { | ||
if (context === void 0) { context = object; } | ||
var callable = isEmptyPath(path) | ||
? object | ||
: getValueAtPath(path, object); | ||
var callable = isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
return callIfFunction(callable, context, parameters); | ||
}; | ||
}; | ||
/** | ||
* @function createGet | ||
* | ||
* @description | ||
* create handlers for get / getWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns get / getWith | ||
*/ | ||
var createGet = function (isWithHandler) { | ||
} | ||
function createGet(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function getWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -500,22 +484,13 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (path, object) { | ||
return function get(path, object) { | ||
return isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
}; | ||
}; | ||
/** | ||
* @function createGetOr | ||
* | ||
* @description | ||
* create handlers for getOr / getWithOr | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns getOr / getWithOr | ||
*/ | ||
var createGetOr = function (isWithHandler) { | ||
} | ||
function createGetOr(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, noMatchValue, path, object) { | ||
return function getWithOr(fn, noMatchValue, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -528,22 +503,13 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (noMatchValue, path, object) { | ||
return function getOr(noMatchValue, path, object) { | ||
return isEmptyPath(path) ? object : getValueAtPath(path, object, noMatchValue); | ||
}; | ||
}; | ||
/** | ||
* @function createHas | ||
* | ||
* @description | ||
* create handlers for has / hasWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns has / hasWith | ||
*/ | ||
var createHas = function (isWithHandler) { | ||
} | ||
function createHas(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function hasWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (isEmptyPath(path)) { | ||
@@ -556,24 +522,13 @@ return !!fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (path, object) { | ||
return isEmptyPath(path) | ||
? object != null | ||
: getValueAtPath(path, object) !== void 0; | ||
return function has(path, object) { | ||
return isEmptyPath(path) ? object != null : getValueAtPath(path, object) !== void 0; | ||
}; | ||
}; | ||
/** | ||
* @function createIs | ||
* | ||
* @description | ||
* create handlers for is / isWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns is / isWith | ||
*/ | ||
var createIs = function (isWithHandler) { | ||
} | ||
function createIs(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, value, object) { | ||
return function isWith(fn, path, value, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -585,25 +540,14 @@ return isSameValueZero(fn.apply(void 0, [object].concat(extraArgs)), value); | ||
} | ||
return function (path, value, object) { | ||
return isEmptyPath(path) | ||
? isSameValueZero(object, value) | ||
: isSameValueZero(getValueAtPath(path, object), value); | ||
return function is(path, value, object) { | ||
var _path = isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
return isSameValueZero(_path, value); | ||
}; | ||
}; | ||
/** | ||
* @function createMerge | ||
* | ||
* @description | ||
* create handlers for merge / mergeWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @param isDeep is the handler for a deep merge or shallow | ||
* @returns merge / mergeWith | ||
*/ | ||
var createMerge = function (isWithHandler, isDeep) { | ||
} | ||
function createMerge(isWithHandler, isDeep) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function mergeWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (!isCloneable(object)) { | ||
@@ -614,5 +558,3 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
var objectToMerge = fn.apply(void 0, [object].concat(extraArgs)); | ||
return objectToMerge | ||
? getMergedObject(object, objectToMerge, isDeep) | ||
: object; | ||
return objectToMerge ? getMergedObject(object, objectToMerge, isDeep) : object; | ||
} | ||
@@ -630,3 +572,3 @@ var hasChanged = false; | ||
} | ||
return function (path, objectToMerge, object) { | ||
return function merge(path, objectToMerge, object) { | ||
if (!isCloneable(object)) { | ||
@@ -641,34 +583,16 @@ return objectToMerge; | ||
}; | ||
}; | ||
/** | ||
* @function createNot | ||
* | ||
* @description | ||
* create handlers for not / notWith | ||
* | ||
* @param isWithHandler not the method using a with handler | ||
* @returns not / notWithHandler | ||
*/ | ||
var createNot = function (isWithHandler) { | ||
} | ||
function createNot(isWithHandler) { | ||
var is = createIs(isWithHandler); | ||
return function () { | ||
return function not() { | ||
return !is.apply(this, arguments); | ||
}; | ||
}; | ||
/** | ||
* @function createRemove | ||
* | ||
* @description | ||
* create handlers for remove / removeWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns remove / removeWith | ||
*/ | ||
var createRemove = function (isWithHandler) { | ||
} | ||
function createRemove(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function removeWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (isEmptyPath(path)) { | ||
@@ -691,3 +615,3 @@ var emptyObject = getNewEmptyObject(object); | ||
} | ||
return function (path, object) { | ||
return function remove(path, object) { | ||
if (isEmptyPath(path)) { | ||
@@ -707,19 +631,10 @@ return getNewEmptyObject(object); | ||
}; | ||
}; | ||
/** | ||
* @function createSet | ||
* | ||
* @description | ||
* create handlers for set / setWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns set / setWith | ||
*/ | ||
var createSet = function (isWithHandler) { | ||
} | ||
function createSet(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function setWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
return isEmptyPath(path) | ||
@@ -731,3 +646,3 @@ ? fn.apply(void 0, [object].concat(extraArgs)) : getDeepClone(path, object, function (ref, key) { | ||
} | ||
return function (path, value, object) { | ||
return function set(path, value, object) { | ||
return isEmptyPath(path) | ||
@@ -739,47 +654,40 @@ ? value | ||
}; | ||
}; | ||
/** | ||
* @function createAdd | ||
* | ||
* @description | ||
* create handlers for add / addWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns add / addWith | ||
*/ | ||
var createAdd = function (isWithHandler) { | ||
var add = createSet(isWithHandler); | ||
} | ||
function createAdd(isWithHandler) { | ||
var _add = createSet(isWithHandler); | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return add.apply(this, [fn, getFullPath(path, object, fn), object].concat(slice.call(arguments, 3))); | ||
return function addWith(fn, path, object) { | ||
return _add.apply(this, [fn, getFullPath(path, object, fn), object].concat(slice(arguments, 3))); | ||
}; | ||
} | ||
return function (path, value, object) { return add(getFullPath(path, object), value, object); }; | ||
}; | ||
return function add(path, value, object) { | ||
return _add(getFullPath(path, object), value, object); | ||
}; | ||
} | ||
// external dependencies | ||
var add = curry(createAdd(false), 3); | ||
var addWith = curry(createAdd(true), 3); | ||
var assign$1 = curry(createMerge(false, false), 3); | ||
var assignWith = curry(createMerge(true, false), 3); | ||
var add = curry(createAdd(false)); | ||
var addWith = curry(createAdd(true)); | ||
var assign$1 = curry(createMerge(false, false)); | ||
var assignWith = curry(createMerge(true, false)); | ||
var call = curry(createCall(false), 3); | ||
var callWith = curry(createCall(true), 4); | ||
var get = curry(createGet(false), 2); | ||
var getOr = curry(createGetOr(false), 3); | ||
var getWith = curry(createGet(true), 3); | ||
var getWithOr = curry(createGetOr(true), 4); | ||
var has = curry(createHas(false), 2); | ||
var hasWith = curry(createHas(true), 3); | ||
var is = curry(createIs(false), 3); | ||
var isWith = curry(createIs(true), 4); | ||
var merge = curry(createMerge(false, true), 3); | ||
var mergeWith = curry(createMerge(true, true), 3); | ||
var not = curry(createNot(false), 3); | ||
var notWith = curry(createNot(true), 4); | ||
var remove = curry(createRemove(false), 2); | ||
var removeWith = curry(createRemove(true), 3); | ||
var set = curry(createSet(false), 3); | ||
var setWith = curry(createSet(true), 3); | ||
var get = curry(createGet(false)); | ||
var getOr = curry(createGetOr(false)); | ||
var getWith = curry(createGet(true)); | ||
var getWithOr = curry(createGetOr(true)); | ||
var has = curry(createHas(false)); | ||
var hasWith = curry(createHas(true)); | ||
var is = curry(createIs(false)); | ||
var isWith = curry(createIs(true)); | ||
var merge = curry(createMerge(false, true)); | ||
var mergeWith = curry(createMerge(true, true)); | ||
var not = curry(createNot(false)); | ||
var notWith = curry(createNot(true)); | ||
var remove = curry(createRemove(false)); | ||
var removeWith = curry(createRemove(true)); | ||
var set = curry(createSet(false)); | ||
var setWith = curry(createSet(true)); | ||
export { add, addWith, assign$1 as assign, assignWith, call, callWith, get, getOr, getWith, getWithOr, has, hasWith, is, isWith, merge, mergeWith, not, notWith, remove, removeWith, set, setWith }; | ||
//# sourceMappingURL=unchanged.esm.js.map |
@@ -10,11 +10,13 @@ (function (global, factory) { | ||
var create = O.create, getOwnPropertySymbols = O.getOwnPropertySymbols, getPrototypeOf = O.getPrototypeOf, keys = O.keys, propertyIsEnumerable = O.propertyIsEnumerable; | ||
var toStringObject = O.prototype.toString; | ||
var toStringFunction = Function.prototype.toString; | ||
var isArray = Array.isArray; | ||
var toStringFunction = Function.prototype.bind.call(Function.prototype.call, Function.prototype.toString); | ||
var toStringObject = Function.prototype.bind.call(Function.prototype.call, O.prototype.toString); | ||
/** | ||
* @constant HAS_SYMBOL_SUPPORT are Symbols supported | ||
*/ | ||
var HAS_SYMBOL_SUPPORT = typeof Symbol === 'function' && typeof Symbol.for === 'function'; | ||
/** | ||
* @constant REACT_ELEMENT the symbol / number specific to react elements | ||
*/ | ||
var REACT_ELEMENT = typeof Symbol === 'function' && typeof Symbol.for === 'function' | ||
? Symbol.for('react.element') | ||
: 0xeac7; | ||
var REACT_ELEMENT = HAS_SYMBOL_SUPPORT ? Symbol.for('react.element') : 0xeac7; | ||
/** | ||
@@ -30,5 +32,5 @@ * @function cloneArray | ||
var cloneArray = function (array) { | ||
// @ts-ignore | ||
var cloned = new array.constructor(); | ||
for (var index = 0; index < array.length; index++) { | ||
var Constructor = array.constructor; | ||
var cloned = Constructor === Array ? [] : new Constructor(); | ||
for (var index = 0, length_1 = array.length; index < length_1; index++) { | ||
cloned[index] = array[index]; | ||
@@ -51,3 +53,3 @@ } | ||
var value = initialValue; | ||
for (var index = 0; index < array.length; index++) { | ||
for (var index = 0, length_2 = array.length; index < length_2; index++) { | ||
value = fn(value, array[index]); | ||
@@ -67,2 +69,5 @@ } | ||
var getOwnProperties = function (object) { | ||
if (!HAS_SYMBOL_SUPPORT) { | ||
return keys(object); | ||
} | ||
var ownSymbols = getOwnPropertySymbols(object); | ||
@@ -108,3 +113,5 @@ if (!ownSymbols.length) { | ||
*/ | ||
var createWithProto = function (object) { return create(object.__proto__ || getPrototypeOf(object)); }; | ||
var createWithProto = function (object) { | ||
return create(object.__proto__ || getPrototypeOf(object)); | ||
}; | ||
/** | ||
@@ -120,8 +127,6 @@ * @function isCloneable | ||
var isCloneable = function (object) { | ||
if (!object || | ||
typeof object !== 'object' || | ||
object.$$typeof === REACT_ELEMENT) { | ||
if (!object || typeof object !== 'object' || object.$$typeof === REACT_ELEMENT) { | ||
return false; | ||
} | ||
var type = toStringObject.call(object); | ||
var type = toStringObject(object); | ||
return type !== '[object Date]' && type !== '[object RegExp]'; | ||
@@ -138,5 +143,3 @@ }; | ||
*/ | ||
var isEmptyPath = function (path) { | ||
return path == null || (isArray(path) && !path.length); | ||
}; | ||
var isEmptyPath = function (path) { return path == null || (isArray(path) && !path.length); }; | ||
/** | ||
@@ -152,4 +155,3 @@ * @function isGlobalConstructor | ||
var isGlobalConstructor = function (fn) { | ||
return typeof fn === 'function' && | ||
!!~toStringFunction.call(fn).indexOf('[native code]'); | ||
return typeof fn === 'function' && !!~toStringFunction(fn).indexOf('[native code]'); | ||
}; | ||
@@ -191,3 +193,5 @@ /** | ||
*/ | ||
var getNewEmptyObject = function (object) { return (isArray(object) ? [] : {}); }; | ||
var getNewEmptyObject = function (object) { | ||
return isArray(object) ? [] : {}; | ||
}; | ||
/** | ||
@@ -209,5 +213,3 @@ * @function getShallowClone | ||
} | ||
return isGlobalConstructor(object.constructor) | ||
? {} | ||
: assign(createWithProto(object), object); | ||
return isGlobalConstructor(object.constructor) ? {} : assign(createWithProto(object), object); | ||
}; | ||
@@ -263,3 +265,5 @@ /** | ||
*/ | ||
var getCoalescedValue = function (value, fallbackValue) { return (value === void 0 ? fallbackValue : value); }; | ||
var getCoalescedValue = function (value, fallbackValue) { | ||
return value === void 0 ? fallbackValue : value; | ||
}; | ||
/** | ||
@@ -274,3 +278,5 @@ * @function getParsedPath | ||
*/ | ||
var getParsedPath = function (path) { return (isArray(path) ? path : pathington.parse(path)); }; | ||
var getParsedPath = function (path) { | ||
return isArray(path) ? path : pathington.parse(path); | ||
}; | ||
/** | ||
@@ -364,5 +370,3 @@ * @function getCloneAtPath | ||
if (parsedPath.length === 1) { | ||
return object | ||
? getCoalescedValue(object[parsedPath[0]], noMatchValue) | ||
: noMatchValue; | ||
return object ? getCoalescedValue(object[parsedPath[0]], noMatchValue) : noMatchValue; | ||
} | ||
@@ -415,9 +419,9 @@ var ref = object; | ||
if (array.length) { | ||
var length_1 = array.length; | ||
var cutoff = array.length - 1; | ||
var index = splicedIndex; | ||
while (index < length_1 - 1) { | ||
while (index < cutoff) { | ||
array[index] = array[index + 1]; | ||
++index; | ||
} | ||
--array.length; | ||
array.length = cutoff; | ||
} | ||
@@ -439,15 +443,6 @@ }; | ||
var isArray$1 = Array.isArray; | ||
var slice = Array.prototype.slice; | ||
/** | ||
* @function createCall | ||
* | ||
* @description | ||
* create handlers for call / callWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns call / callWith | ||
*/ | ||
var createCall = function (isWithHandler) { | ||
var slice = Function.prototype.bind.call(Function.prototype.bind, Array.prototype.slice); | ||
function createCall(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, parameters, object, context) { | ||
return function callWith(fn, path, parameters, object, context) { | ||
if (context === void 0) { context = object; } | ||
@@ -457,3 +452,3 @@ if (typeof fn !== 'function') { | ||
} | ||
var extraArgs = slice.call(arguments, 5); | ||
var extraArgs = slice(arguments, 5); | ||
if (isEmptyPath(path)) { | ||
@@ -470,26 +465,15 @@ return callIfFunction(fn.apply(void 0, [object].concat(extraArgs)), context, parameters); | ||
} | ||
return function (path, parameters, object, context) { | ||
return function call(path, parameters, object, context) { | ||
if (context === void 0) { context = object; } | ||
var callable = isEmptyPath(path) | ||
? object | ||
: getValueAtPath(path, object); | ||
var callable = isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
return callIfFunction(callable, context, parameters); | ||
}; | ||
}; | ||
/** | ||
* @function createGet | ||
* | ||
* @description | ||
* create handlers for get / getWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns get / getWith | ||
*/ | ||
var createGet = function (isWithHandler) { | ||
} | ||
function createGet(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function getWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -502,22 +486,13 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (path, object) { | ||
return function get(path, object) { | ||
return isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
}; | ||
}; | ||
/** | ||
* @function createGetOr | ||
* | ||
* @description | ||
* create handlers for getOr / getWithOr | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns getOr / getWithOr | ||
*/ | ||
var createGetOr = function (isWithHandler) { | ||
} | ||
function createGetOr(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, noMatchValue, path, object) { | ||
return function getWithOr(fn, noMatchValue, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -530,22 +505,13 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (noMatchValue, path, object) { | ||
return function getOr(noMatchValue, path, object) { | ||
return isEmptyPath(path) ? object : getValueAtPath(path, object, noMatchValue); | ||
}; | ||
}; | ||
/** | ||
* @function createHas | ||
* | ||
* @description | ||
* create handlers for has / hasWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns has / hasWith | ||
*/ | ||
var createHas = function (isWithHandler) { | ||
} | ||
function createHas(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function hasWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (isEmptyPath(path)) { | ||
@@ -558,24 +524,13 @@ return !!fn.apply(void 0, [object].concat(extraArgs)); | ||
} | ||
return function (path, object) { | ||
return isEmptyPath(path) | ||
? object != null | ||
: getValueAtPath(path, object) !== void 0; | ||
return function has(path, object) { | ||
return isEmptyPath(path) ? object != null : getValueAtPath(path, object) !== void 0; | ||
}; | ||
}; | ||
/** | ||
* @function createIs | ||
* | ||
* @description | ||
* create handlers for is / isWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns is / isWith | ||
*/ | ||
var createIs = function (isWithHandler) { | ||
} | ||
function createIs(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, value, object) { | ||
return function isWith(fn, path, value, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 4); | ||
var extraArgs = slice(arguments, 4); | ||
if (isEmptyPath(path)) { | ||
@@ -587,25 +542,14 @@ return isSameValueZero(fn.apply(void 0, [object].concat(extraArgs)), value); | ||
} | ||
return function (path, value, object) { | ||
return isEmptyPath(path) | ||
? isSameValueZero(object, value) | ||
: isSameValueZero(getValueAtPath(path, object), value); | ||
return function is(path, value, object) { | ||
var _path = isEmptyPath(path) ? object : getValueAtPath(path, object); | ||
return isSameValueZero(_path, value); | ||
}; | ||
}; | ||
/** | ||
* @function createMerge | ||
* | ||
* @description | ||
* create handlers for merge / mergeWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @param isDeep is the handler for a deep merge or shallow | ||
* @returns merge / mergeWith | ||
*/ | ||
var createMerge = function (isWithHandler, isDeep) { | ||
} | ||
function createMerge(isWithHandler, isDeep) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function mergeWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (!isCloneable(object)) { | ||
@@ -616,5 +560,3 @@ return fn.apply(void 0, [object].concat(extraArgs)); | ||
var objectToMerge = fn.apply(void 0, [object].concat(extraArgs)); | ||
return objectToMerge | ||
? getMergedObject(object, objectToMerge, isDeep) | ||
: object; | ||
return objectToMerge ? getMergedObject(object, objectToMerge, isDeep) : object; | ||
} | ||
@@ -632,3 +574,3 @@ var hasChanged = false; | ||
} | ||
return function (path, objectToMerge, object) { | ||
return function merge(path, objectToMerge, object) { | ||
if (!isCloneable(object)) { | ||
@@ -643,34 +585,16 @@ return objectToMerge; | ||
}; | ||
}; | ||
/** | ||
* @function createNot | ||
* | ||
* @description | ||
* create handlers for not / notWith | ||
* | ||
* @param isWithHandler not the method using a with handler | ||
* @returns not / notWithHandler | ||
*/ | ||
var createNot = function (isWithHandler) { | ||
} | ||
function createNot(isWithHandler) { | ||
var is = createIs(isWithHandler); | ||
return function () { | ||
return function not() { | ||
return !is.apply(this, arguments); | ||
}; | ||
}; | ||
/** | ||
* @function createRemove | ||
* | ||
* @description | ||
* create handlers for remove / removeWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns remove / removeWith | ||
*/ | ||
var createRemove = function (isWithHandler) { | ||
} | ||
function createRemove(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function removeWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
if (isEmptyPath(path)) { | ||
@@ -693,3 +617,3 @@ var emptyObject = getNewEmptyObject(object); | ||
} | ||
return function (path, object) { | ||
return function remove(path, object) { | ||
if (isEmptyPath(path)) { | ||
@@ -709,19 +633,10 @@ return getNewEmptyObject(object); | ||
}; | ||
}; | ||
/** | ||
* @function createSet | ||
* | ||
* @description | ||
* create handlers for set / setWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns set / setWith | ||
*/ | ||
var createSet = function (isWithHandler) { | ||
} | ||
function createSet(isWithHandler) { | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return function setWith(fn, path, object) { | ||
if (typeof fn !== 'function') { | ||
throwInvalidFnError(); | ||
} | ||
var extraArgs = slice.call(arguments, 3); | ||
var extraArgs = slice(arguments, 3); | ||
return isEmptyPath(path) | ||
@@ -733,3 +648,3 @@ ? fn.apply(void 0, [object].concat(extraArgs)) : getDeepClone(path, object, function (ref, key) { | ||
} | ||
return function (path, value, object) { | ||
return function set(path, value, object) { | ||
return isEmptyPath(path) | ||
@@ -741,47 +656,45 @@ ? value | ||
}; | ||
}; | ||
/** | ||
* @function createAdd | ||
* | ||
* @description | ||
* create handlers for add / addWith | ||
* | ||
* @param isWithHandler is the method using a with handler | ||
* @returns add / addWith | ||
*/ | ||
var createAdd = function (isWithHandler) { | ||
var add = createSet(isWithHandler); | ||
} | ||
function createAdd(isWithHandler) { | ||
var _add = createSet(isWithHandler); | ||
if (isWithHandler) { | ||
return function (fn, path, object) { | ||
return add.apply(this, [fn, getFullPath(path, object, fn), object].concat(slice.call(arguments, 3))); | ||
return function addWith(fn, path, object) { | ||
return _add.apply(this, [fn, getFullPath(path, object, fn), object].concat(slice(arguments, 3))); | ||
}; | ||
} | ||
return function (path, value, object) { return add(getFullPath(path, object), value, object); }; | ||
}; | ||
return function add(path, value, object) { | ||
return _add(getFullPath(path, object), value, object); | ||
}; | ||
} | ||
// external dependencies | ||
var add = curriable.curry(createAdd(false), 3); | ||
var addWith = curriable.curry(createAdd(true), 3); | ||
var assign$1 = curriable.curry(createMerge(false, false), 3); | ||
var assignWith = curriable.curry(createMerge(true, false), 3); | ||
var add = curriable.curry(createAdd(false)); | ||
var addWith = curriable.curry(createAdd(true)); | ||
var assign$1 = curriable.curry(createMerge(false, false)); | ||
var assignWith = curriable.curry(createMerge(true, false)); | ||
var call = curriable.curry(createCall(false), 3); | ||
var callWith = curriable.curry(createCall(true), 4); | ||
var get = curriable.curry(createGet(false), 2); | ||
var getOr = curriable.curry(createGetOr(false), 3); | ||
var getWith = curriable.curry(createGet(true), 3); | ||
var getWithOr = curriable.curry(createGetOr(true), 4); | ||
var has = curriable.curry(createHas(false), 2); | ||
var hasWith = curriable.curry(createHas(true), 3); | ||
var is = curriable.curry(createIs(false), 3); | ||
var isWith = curriable.curry(createIs(true), 4); | ||
var merge = curriable.curry(createMerge(false, true), 3); | ||
var mergeWith = curriable.curry(createMerge(true, true), 3); | ||
var not = curriable.curry(createNot(false), 3); | ||
var notWith = curriable.curry(createNot(true), 4); | ||
var remove = curriable.curry(createRemove(false), 2); | ||
var removeWith = curriable.curry(createRemove(true), 3); | ||
var set = curriable.curry(createSet(false), 3); | ||
var setWith = curriable.curry(createSet(true), 3); | ||
var get = curriable.curry(createGet(false)); | ||
var getOr = curriable.curry(createGetOr(false)); | ||
var getWith = curriable.curry(createGet(true)); | ||
var getWithOr = curriable.curry(createGetOr(true)); | ||
var has = curriable.curry(createHas(false)); | ||
var hasWith = curriable.curry(createHas(true)); | ||
var is = curriable.curry(createIs(false)); | ||
var isWith = curriable.curry(createIs(true)); | ||
var merge = curriable.curry(createMerge(false, true)); | ||
var mergeWith = curriable.curry(createMerge(true, true)); | ||
var not = curriable.curry(createNot(false)); | ||
var notWith = curriable.curry(createNot(true)); | ||
var remove = curriable.curry(createRemove(false)); | ||
var removeWith = curriable.curry(createRemove(true)); | ||
var set = curriable.curry(createSet(false)); | ||
var setWith = curriable.curry(createSet(true)); | ||
exports.__ = curriable.__; | ||
Object.defineProperty(exports, '__', { | ||
enumerable: true, | ||
get: function () { | ||
return curriable.__; | ||
} | ||
}); | ||
exports.add = add; | ||
@@ -788,0 +701,0 @@ exports.addWith = addWith; |
@@ -1,1 +0,1 @@ | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("curriable"),require("pathington")):"function"==typeof define&&define.amd?define(["exports","curriable","pathington"],r):r((n=n||self).unchanged={},n.curriable,n.pathington)}(this,function(n,r,t){"use strict";var o=Object,u=o.create,c=o.getOwnPropertySymbols,e=o.getPrototypeOf,i=o.keys,f=o.propertyIsEnumerable,a=o.prototype.toString,p=Function.prototype.toString,l=Array.isArray,y="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("react.element"):60103,v=function(n,r,t){for(var o=t,u=0;u<n.length;u++)o=r(o,n[u]);return o},d=function(n){var r=c(n);return r.length?i(n).concat(v(r,function(r,t){return f.call(n,t)&&r.push(t),r},[])):i(n)},s="function"==typeof o.assign?o.assign:function(n,r){return r?v(d(r),function(n,t){return n[t]=r[t],n},Object(n)):n},h=function(n){return u(n.__proto__||e(n))},g=function(n){if(!n||"object"!=typeof n||n.$$typeof===y)return!1;var r=a.call(n);return"[object Date]"!==r&&"[object RegExp]"!==r},b=function(n){return null==n||l(n)&&!n.length},m=function(n){return"function"==typeof n&&!!~p.call(n).indexOf("[native code]")},W=function(n,r,t){return"function"==typeof n?n.apply(r,t):void 0},_=function(n){return l(n)?[]:{}},O=function(n){return n.constructor===o?s({},n):l(n)?function(n){for(var r=new n.constructor,t=0;t<n.length;t++)r[t]=n[t];return r}(n):m(n.constructor)?{}:s(h(n),n)},j=function(n,r){return n===r||n!=n&&r!=r},S=function(n,r){return g(n)?O(n):"number"==typeof r?[]:{}},x=function(n,r){return void 0===n?r:n},A=function(n){return l(n)?n:t.parse(n)},w=function(n,r,t,o){var u=n[o],c=o+1;return c===n.length?t(r,u):r[u]=w(n,S(r[u],n[c]),t,c),r},E=function(n,r,t){var o=A(n),u=S(r,o[0]);return 1===o.length?(t(u,o[0]),u):w(o,u,t,0)},P=function(n,r,t){var u,c=l(n);if(c!==l(r)||!g(n))return g(u=r)?O(u):u;if(c)return n.concat(r);var e=n.constructor===o||m(n.constructor)?{}:h(n);return v(d(r),function(o,u){return o[u]=t&&g(r[u])?P(n[u],r[u],t):r[u],o},s(e,n))},q=function(n,r,t){var o=A(n);if(1===o.length)return r?x(r[o[0]],t):t;for(var u=r,c=o[0],e=0;e<o.length-1;e++){if(!u||!u[c])return t;u=u[c],c=o[e+1]}return u?x(u[c],t):t},$=function(n,r,t){var o=b(n),u=o?r:t?t(q(n,r)):q(n,r);return l(u)?l(n)?n.concat([u.length]):(o?"":n)+"["+u.length+"]":n},k=function(n,r){if(n.length){for(var t=n.length,o=r;o<t-1;)n[o]=n[o+1],++o;--n.length}},D=function(){throw new TypeError('handler passed is not of type "function".')},F=Array.isArray,I=Array.prototype.slice,M=function(n){return n?function(n,r,t,o,u){void 0===u&&(u=o),"function"!=typeof n&&D();var c=I.call(arguments,5);if(b(r))return W(n.apply(void 0,[o].concat(c)),u,t);var e=q(r,o);if(void 0!==e){var i=n.apply(void 0,[e].concat(c));return W(i,u,t)}}:function(n,r,t,o){void 0===o&&(o=t);var u=b(n)?t:q(n,t);return W(u,o,r)}},R=function(n){return n?function(n,r,t){"function"!=typeof n&&D();var o=I.call(arguments,4);if(b(r))return n.apply(void 0,[t].concat(o));var u=q(r,t);return void 0===u?u:n.apply(void 0,[u].concat(o))}:function(n,r){return b(n)?r:q(n,r)}},T=function(n){return n?function(n,r,t,o){"function"!=typeof n&&D();var u=I.call(arguments,4);if(b(t))return n.apply(void 0,[o].concat(u));var c=q(t,o);return void 0===c?r:n.apply(void 0,[c].concat(u))}:function(n,r,t){return b(r)?t:q(r,t,n)}},z=function(n){return n?function(n,r,t){"function"!=typeof n&&D();var o=I.call(arguments,3);if(b(r))return!!n.apply(void 0,[t].concat(o));var u=q(r,t);return void 0!==u&&!!n.apply(void 0,[u].concat(o))}:function(n,r){return b(n)?null!=r:void 0!==q(n,r)}},B=function(n){return n?function(n,r,t,o){"function"!=typeof n&&D();var u=I.call(arguments,4);return b(r)?j(n.apply(void 0,[o].concat(u)),t):j(n.apply(void 0,[q(r,o)].concat(u)),t)}:function(n,r,t){return b(n)?j(t,r):j(q(n,t),r)}},C=function(n,r){return n?function(n,t,o){"function"!=typeof n&&D();var u=I.call(arguments,3);if(!g(o))return n.apply(void 0,[o].concat(u));if(b(t)){var c=n.apply(void 0,[o].concat(u));return c?P(o,c,r):o}var e=!1,i=E(t,o,function(t,o){var c=n.apply(void 0,[t[o]].concat(u));c&&(t[o]=P(t[o],c,r),e=!0)});return e?i:o}:function(n,t,o){return g(o)?b(n)?P(o,t,!0):E(n,o,function(n,o){n[o]=P(n[o],t,r)}):t}},G=function(n){var r=B(n);return function(){return!r.apply(this,arguments)}},H=function(n){return n?function(n,r,t){"function"!=typeof n&&D();var o=I.call(arguments,3);if(b(r)){var u=_(t);return n.apply(void 0,[u].concat(o))?u:t}var c=q(r,t);return void 0!==c&&n.apply(void 0,[c].concat(o))?E(r,t,function(n,r){F(n)?k(n,r):delete n[r]}):t}:function(n,r){return b(n)?_(r):void 0!==q(n,r)?E(n,r,function(n,r){F(n)?k(n,r):delete n[r]}):r}},J=function(n){return n?function(n,r,t){"function"!=typeof n&&D();var o=I.call(arguments,3);return b(r)?n.apply(void 0,[t].concat(o)):E(r,t,function(r,t){r[t]=n.apply(void 0,[r[t]].concat(o))})}:function(n,r,t){return b(n)?r:E(n,t,function(n,t){n[t]=r})}},K=function(n){var r=J(n);return n?function(n,t,o){return r.apply(this,[n,$(t,o,n),o].concat(I.call(arguments,3)))}:function(n,t,o){return r($(n,o),t,o)}},L=r.curry(K(!1),3),N=r.curry(K(!0),3),Q=r.curry(C(!1,!1),3),U=r.curry(C(!0,!1),3),V=r.curry(M(!1),3),X=r.curry(M(!0),4),Y=r.curry(R(!1),2),Z=r.curry(T(!1),3),nn=r.curry(R(!0),3),rn=r.curry(T(!0),4),tn=r.curry(z(!1),2),on=r.curry(z(!0),3),un=r.curry(B(!1),3),cn=r.curry(B(!0),4),en=r.curry(C(!1,!0),3),fn=r.curry(C(!0,!0),3),an=r.curry(G(!1),3),pn=r.curry(G(!0),4),ln=r.curry(H(!1),2),yn=r.curry(H(!0),3),vn=r.curry(J(!1),3),dn=r.curry(J(!0),3);n.__=r.__,n.add=L,n.addWith=N,n.assign=Q,n.assignWith=U,n.call=V,n.callWith=X,n.get=Y,n.getOr=Z,n.getWith=nn,n.getWithOr=rn,n.has=tn,n.hasWith=on,n.is=un,n.isWith=cn,n.merge=en,n.mergeWith=fn,n.not=an,n.notWith=pn,n.remove=ln,n.removeWith=yn,n.set=vn,n.setWith=dn,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("curriable"),require("pathington")):"function"==typeof define&&define.amd?define(["exports","curriable","pathington"],t):t((n=n||self).unchanged={},n.curriable,n.pathington)}(this,function(n,t,r){"use strict";var o=Object,e=o.create,u=o.getOwnPropertySymbols,c=o.getPrototypeOf,i=o.keys,f=o.propertyIsEnumerable,a=Array.isArray,p=Function.prototype.bind.call(Function.prototype.call,Function.prototype.toString),y=Function.prototype.bind.call(Function.prototype.call,o.prototype.toString),l="function"==typeof Symbol&&"function"==typeof Symbol.for,v=l?Symbol.for("react.element"):60103,d=function(n,t,r){for(var o=r,e=0,u=n.length;e<u;e++)o=t(o,n[e]);return o},s=function(n){if(!l)return i(n);var t=u(n);return t.length?i(n).concat(d(t,function(t,r){return f.call(n,r)&&t.push(r),t},[])):i(n)},h="function"==typeof o.assign?o.assign:function(n,t){return t?d(s(t),function(n,r){return n[r]=t[r],n},Object(n)):n},g=function(n){return e(n.__proto__||c(n))},b=function(n){if(!n||"object"!=typeof n||n.$$typeof===v)return!1;var t=y(n);return"[object Date]"!==t&&"[object RegExp]"!==t},m=function(n){return null==n||a(n)&&!n.length},W=function(n){return"function"==typeof n&&!!~p(n).indexOf("[native code]")},_=function(n,t,r){return"function"==typeof n?n.apply(t,r):void 0},O=function(n){return a(n)?[]:{}},j=function(n){return n.constructor===o?h({},n):a(n)?function(n){for(var t=n.constructor,r=t===Array?[]:new t,o=0,e=n.length;o<e;o++)r[o]=n[o];return r}(n):W(n.constructor)?{}:h(g(n),n)},F=function(n,t){return n===t||n!=n&&t!=t},A=function(n,t){return b(n)?j(n):"number"==typeof t?[]:{}},S=function(n,t){return void 0===n?t:n},x=function(n){return a(n)?n:r.parse(n)},w=function(n,t,r,o){var e=n[o],u=o+1;return u===n.length?r(t,e):t[e]=w(n,A(t[e],n[u]),r,u),t},P=function(n,t,r){var o=x(n),e=A(t,o[0]);return 1===o.length?(r(e,o[0]),e):w(o,e,r,0)},E=function(n,t,r){var e,u=a(n);if(u!==a(t)||!b(n))return b(e=t)?j(e):e;if(u)return n.concat(t);var c=n.constructor===o||W(n.constructor)?{}:g(n);return d(s(t),function(o,e){return o[e]=r&&b(t[e])?E(n[e],t[e],r):t[e],o},h(c,n))},q=function(n,t,r){var o=x(n);if(1===o.length)return t?S(t[o[0]],r):r;for(var e=t,u=o[0],c=0;c<o.length-1;c++){if(!e||!e[u])return r;e=e[u],u=o[c+1]}return e?S(e[u],r):r},$=function(n,t,r){var o=m(n),e=o?t:r?r(q(n,t)):q(n,t);return a(e)?a(n)?n.concat([e.length]):(o?"":n)+"["+e.length+"]":n},k=function(n,t){if(n.length){for(var r=n.length-1,o=t;o<r;)n[o]=n[o+1],++o;n.length=r}},D=function(){throw new TypeError('handler passed is not of type "function".')},I=Array.isArray,M=Function.prototype.bind.call(Function.prototype.bind,Array.prototype.slice);function R(n){return n?function(n,t,r,o,e){void 0===e&&(e=o),"function"!=typeof n&&D();var u=M(arguments,5);if(m(t))return _(n.apply(void 0,[o].concat(u)),e,r);var c=q(t,o);if(void 0!==c){var i=n.apply(void 0,[c].concat(u));return _(i,e,r)}}:function(n,t,r,o){void 0===o&&(o=r);var e=m(n)?r:q(n,r);return _(e,o,t)}}function T(n){return n?function(n,t,r){"function"!=typeof n&&D();var o=M(arguments,4);if(m(t))return n.apply(void 0,[r].concat(o));var e=q(t,r);return void 0===e?e:n.apply(void 0,[e].concat(o))}:function(n,t){return m(n)?t:q(n,t)}}function z(n){return n?function(n,t,r,o){"function"!=typeof n&&D();var e=M(arguments,4);if(m(r))return n.apply(void 0,[o].concat(e));var u=q(r,o);return void 0===u?t:n.apply(void 0,[u].concat(e))}:function(n,t,r){return m(t)?r:q(t,r,n)}}function B(n){return n?function(n,t,r){"function"!=typeof n&&D();var o=M(arguments,3);if(m(t))return!!n.apply(void 0,[r].concat(o));var e=q(t,r);return void 0!==e&&!!n.apply(void 0,[e].concat(o))}:function(n,t){return m(n)?null!=t:void 0!==q(n,t)}}function C(n){return n?function(n,t,r,o){"function"!=typeof n&&D();var e=M(arguments,4);return m(t)?F(n.apply(void 0,[o].concat(e)),r):F(n.apply(void 0,[q(t,o)].concat(e)),r)}:function(n,t,r){var o=m(n)?r:q(n,r);return F(o,t)}}function G(n,t){return n?function(n,r,o){"function"!=typeof n&&D();var e=M(arguments,3);if(!b(o))return n.apply(void 0,[o].concat(e));if(m(r)){var u=n.apply(void 0,[o].concat(e));return u?E(o,u,t):o}var c=!1,i=P(r,o,function(r,o){var u=n.apply(void 0,[r[o]].concat(e));u&&(r[o]=E(r[o],u,t),c=!0)});return c?i:o}:function(n,r,o){return b(o)?m(n)?E(o,r,!0):P(n,o,function(n,o){n[o]=E(n[o],r,t)}):r}}function H(n){var t=C(n);return function(){return!t.apply(this,arguments)}}function J(n){return n?function(n,t,r){"function"!=typeof n&&D();var o=M(arguments,3);if(m(t)){var e=O(r);return n.apply(void 0,[e].concat(o))?e:r}var u=q(t,r);return void 0!==u&&n.apply(void 0,[u].concat(o))?P(t,r,function(n,t){I(n)?k(n,t):delete n[t]}):r}:function(n,t){return m(n)?O(t):void 0!==q(n,t)?P(n,t,function(n,t){I(n)?k(n,t):delete n[t]}):t}}function K(n){return n?function(n,t,r){"function"!=typeof n&&D();var o=M(arguments,3);return m(t)?n.apply(void 0,[r].concat(o)):P(t,r,function(t,r){t[r]=n.apply(void 0,[t[r]].concat(o))})}:function(n,t,r){return m(n)?t:P(n,r,function(n,r){n[r]=t})}}function L(n){var t=K(n);return n?function(n,r,o){return t.apply(this,[n,$(r,o,n),o].concat(M(arguments,3)))}:function(n,r,o){return t($(n,o),r,o)}}var N=t.curry(L(!1)),Q=t.curry(L(!0)),U=t.curry(G(!1,!1)),V=t.curry(G(!0,!1)),X=t.curry(R(!1),3),Y=t.curry(R(!0),4),Z=t.curry(T(!1)),nn=t.curry(z(!1)),tn=t.curry(T(!0)),rn=t.curry(z(!0)),on=t.curry(B(!1)),en=t.curry(B(!0)),un=t.curry(C(!1)),cn=t.curry(C(!0)),fn=t.curry(G(!1,!0)),an=t.curry(G(!0,!0)),pn=t.curry(H(!1)),yn=t.curry(H(!0)),ln=t.curry(J(!1)),vn=t.curry(J(!0)),dn=t.curry(K(!1)),sn=t.curry(K(!0));Object.defineProperty(n,"__",{enumerable:!0,get:function(){return t.__}}),n.add=N,n.addWith=Q,n.assign=U,n.assignWith=V,n.call=X,n.callWith=Y,n.get=Z,n.getOr=nn,n.getWith=tn,n.getWithOr=rn,n.has=on,n.hasWith=en,n.is=un,n.isWith=cn,n.merge=fn,n.mergeWith=an,n.not=pn,n.notWith=yn,n.remove=ln,n.removeWith=vn,n.set=dn,n.setWith=sn,Object.defineProperty(n,"__esModule",{value:!0})}); |
218
index.d.ts
@@ -0,1 +1,3 @@ | ||
/* eslint-disable */ | ||
declare namespace unchanged { | ||
@@ -11,151 +13,149 @@ export type PathItem = number | string; | ||
export type withHandler = (value: any, ...extraArgs: any[]) => any; | ||
} | ||
export type Fn = (...args: any[]) => any; | ||
declare module 'unchanged' { | ||
export function add( | ||
path: unchanged.Path, | ||
value: any, | ||
object: unchanged.Unchangeable, | ||
): unchanged.Unchangeable; | ||
export type WithHandler = (value: any, ...extraArgs: any[]) => any; | ||
export function addWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
export type Add = (path: Path, value: any, object: Unchangeable) => Unchangeable; | ||
export type AddWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): unchanged.Unchangeable; | ||
) => Unchangeable; | ||
export function assign( | ||
path: unchanged.Path, | ||
objectToAssign: unchanged.Unchangeable, | ||
object: unchanged.Unchangeable, | ||
): unchanged.Unchangeable; | ||
export type Assign = ( | ||
path: Path, | ||
objectToAssign: Unchangeable, | ||
object: Unchangeable, | ||
) => Unchangeable; | ||
export function assignWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
export type AssignWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): unchanged.Unchangeable; | ||
) => Unchangeable; | ||
export function call( | ||
path: unchanged.Path, | ||
export type Call = ( | ||
path: Path, | ||
parameters: any[], | ||
object: unchanged.Unchangeable | Function, | ||
object: Unchangeable | Fn, | ||
context?: any, | ||
): any; | ||
) => any; | ||
export function callWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
export type CallWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
parameters: any[], | ||
object: unchanged.Unchangeable | Function, | ||
object: Unchangeable | Fn, | ||
context?: any, | ||
...extraArgs: any[] | ||
): any; | ||
) => any; | ||
export function get( | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
): any; | ||
export type Get = (path: Path, object: Unchangeable) => any; | ||
export function getOr( | ||
fallbackValue: any, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
): any; | ||
export type GetOr = (fallbackValue: any, path: Path, object: Unchangeable) => any; | ||
export function getWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
export type GetWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): any; | ||
) => any; | ||
export function getWithOr( | ||
fn: unchanged.withHandler, | ||
export type GetWithOr = ( | ||
fn: WithHandler, | ||
fallbackValue: any, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): any; | ||
) => any; | ||
export function has( | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
): boolean; | ||
export type Has = (path: Path, object: Unchangeable) => boolean; | ||
export function hasWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
export type HasWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): boolean; | ||
) => boolean; | ||
export function is( | ||
path: unchanged.Path, | ||
value: any, | ||
object: unchanged.Unchangeable, | ||
): boolean; | ||
export type Is = (path: Path, value: any, object: Unchangeable) => boolean; | ||
export function isWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
export type IsWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
value: any, | ||
object: unchanged.Unchangeable, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): boolean; | ||
) => boolean; | ||
export function merge( | ||
path: unchanged.Path, | ||
objectToMerge: unchanged.Unchangeable, | ||
object: unchanged.Unchangeable, | ||
): unchanged.Unchangeable; | ||
export type Merge = ( | ||
path: Path, | ||
objectToMerge: Unchangeable, | ||
object: Unchangeable, | ||
) => Unchangeable; | ||
export function mergeWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
export type MergeWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): unchanged.Unchangeable; | ||
) => Unchangeable; | ||
export function not( | ||
path: unchanged.Path, | ||
value: any, | ||
object: unchanged.Unchangeable, | ||
): boolean; | ||
export type Not = (path: Path, value: any, object: Unchangeable) => boolean; | ||
export function notWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
export type NotWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
value: any, | ||
object: unchanged.Unchangeable, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): boolean; | ||
) => boolean; | ||
export function remove( | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
): unchanged.Unchangeable; | ||
export type Remove = (path: Path, object: Unchangeable) => Unchangeable; | ||
export function removeWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
export type RemoveWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): unchanged.Unchangeable; | ||
) => Unchangeable; | ||
export function set( | ||
path: unchanged.Path, | ||
value: any, | ||
object: unchanged.Unchangeable, | ||
): unchanged.Unchangeable; | ||
export type Set = (path: Path, value: any, object: Unchangeable) => Unchangeable; | ||
export function setWith( | ||
fn: unchanged.withHandler, | ||
path: unchanged.Path, | ||
object: unchanged.Unchangeable, | ||
export type SetWith = ( | ||
fn: WithHandler, | ||
path: Path, | ||
object: Unchangeable, | ||
...extraArgs: any[] | ||
): unchanged.Unchangeable; | ||
) => Unchangeable; | ||
} | ||
declare module 'unchanged' { | ||
type Curried<Handler extends unchanged.Fn> = import('curriable').Curried<Handler>; | ||
export const add: Curried<unchanged.Add>; | ||
export const addWith: Curried<unchanged.AddWith>; | ||
export const assign: Curried<unchanged.Assign>; | ||
export const assignWith: Curried<unchanged.AssignWith>; | ||
export const call: Curried<unchanged.Call>; | ||
export const callWith: Curried<unchanged.CallWith>; | ||
export const get: Curried<unchanged.Get>; | ||
export const getOr: Curried<unchanged.GetOr>; | ||
export const getWith: Curried<unchanged.GetWith>; | ||
export const getWithOr: Curried<unchanged.GetWithOr>; | ||
export const has: Curried<unchanged.Has>; | ||
export const hasWith: Curried<unchanged.HasWith>; | ||
export const is: Curried<unchanged.Is>; | ||
export const isWith: Curried<unchanged.IsWith>; | ||
export const merge: Curried<unchanged.Merge>; | ||
export const mergeWith: Curried<unchanged.MergeWith>; | ||
export const not: Curried<unchanged.Not>; | ||
export const notWith: Curried<unchanged.NotWith>; | ||
export const remove: Curried<unchanged.Remove>; | ||
export const removeWith: Curried<unchanged.RemoveWith>; | ||
export const set: Curried<unchanged.Set>; | ||
export const setWith: Curried<unchanged.SetWith>; | ||
} |
@@ -16,35 +16,34 @@ { | ||
"dependencies": { | ||
"curriable": "^1.2.4", | ||
"pathington": "^1.1.5" | ||
"curriable": "^1.3.0", | ||
"pathington": "^1.1.7" | ||
}, | ||
"description": "A tiny, fast, unopinionated handler for updating JS objects and arrays immutably", | ||
"devDependencies": { | ||
"@types/jest": "^23.3.12", | ||
"@types/node": "^10.12.18", | ||
"@types/ramda": "^0.25.45", | ||
"@types/react": "^16.7.18", | ||
"@types/jest": "^24.0.15", | ||
"@types/node": "^12.6.1", | ||
"@types/ramda": "^0.26.15", | ||
"@types/react": "^16.8.23", | ||
"benchmark": "^2.1.4", | ||
"cli-table": "^0.3.1", | ||
"eslint": "^5.12.0", | ||
"eslint": "^6.0.1", | ||
"html-webpack-plugin": "^3.2.0", | ||
"in-publish": "^2.0.0", | ||
"jest": "^23.6.0", | ||
"jest": "^24.8.0", | ||
"lodash": "^4.17.10", | ||
"nyc": "^13.0.1", | ||
"nyc": "^14.1.1", | ||
"ramda": "^0.26.1", | ||
"react": "^16.7.0", | ||
"react-dom": "^16.4.2", | ||
"rollup": "^1.1.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"rollup-plugin-terser": "^4.0.2", | ||
"rollup-plugin-typescript2": "^0.18.1", | ||
"ts-jest": "^23.10.4", | ||
"ts-loader": "^5.3.3", | ||
"tslint": "^5.11.0", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"rollup": "^1.16.6", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^5.1.1", | ||
"rollup-plugin-typescript2": "^0.21.2", | ||
"ts-jest": "^24.0.2", | ||
"ts-loader": "^6.0.4", | ||
"tslint": "^5.18.0", | ||
"tslint-config-airbnb": "^5.11.0", | ||
"tslint-loader": "^3.5.4", | ||
"typescript": "^3.1.3", | ||
"webpack": "^4.16.5", | ||
"webpack-cli": "^3.2.0", | ||
"webpack-dev-server": "^3.1.5" | ||
"typescript": "^3.5.3", | ||
"webpack": "^4.35.3", | ||
"webpack-cli": "^3.3.5", | ||
"webpack-dev-server": "^3.7.2" | ||
}, | ||
@@ -72,12 +71,14 @@ "keywords": [ | ||
"lint:fix": "npm run lint -- --fix", | ||
"prepublish": "if in-publish; then npm run prepublish:compile; fi", | ||
"prepublish:compile": "npm run lint && npm run test:coverage && npm run dist", | ||
"prepublishOnly": "npm run lint && npm run typecheck && npm run test:coverage && npm run dist", | ||
"release": "release-it", | ||
"release:beta": "release-it --config=.release-it.beta.json", | ||
"start": "npm run dev", | ||
"test": "NODE_PATH=. jest", | ||
"test:coverage": "npm run test -- --coverage", | ||
"test:watch": "npm run test -- --watch" | ||
"test:watch": "npm run test -- --watch", | ||
"typecheck": "tsc --noEmit" | ||
}, | ||
"sideEffects": false, | ||
"types": "dist/index.d.ts", | ||
"version": "2.1.0" | ||
"version": "2.2.0-beta.0" | ||
} |
# unchanged | ||
A tiny (~2.0kB minified+gzipped), [fast](https://github.com/planttheidea/unchanged/blob/master/benchmark_results.csv), unopinionated handler for updating JS objects and arrays immutably. | ||
A tiny (~2.1kB minified+gzipped), [fast](https://github.com/planttheidea/unchanged/blob/master/benchmark_results.csv), unopinionated handler for updating JS objects and arrays immutably. | ||
@@ -9,36 +9,38 @@ Supports nested key paths via path arrays or [dotty syntax](https://github.com/planttheidea/pathington), and all methods are curriable (with placeholder support) for composability. Can be a drop-in replacement for the `lodash/fp` methods `get`, `set`, `merge`, and `omit` with a 90% smaller footprint. | ||
- [Usage](#usage) | ||
- [Types](#types) | ||
- [Standard methods](#standard-methods) | ||
- [get](#get) | ||
- [getOr](#getor) | ||
- [set](#set) | ||
- [remove](#remove) | ||
- [has](#has) | ||
- [is](#is) | ||
- [not](#not) | ||
- [add](#add) | ||
- [merge](#merge) | ||
- [assign](#assign) | ||
- [call](#call) | ||
- [Transform methods](#transform-methods) | ||
- [getWith](#getwith) | ||
- [getWithOr](#getwithor) | ||
- [setWith](#setwith) | ||
- [removeWith](#removewith) | ||
- [hasWith](#haswith) | ||
- [isWith](#iswith) | ||
- [notWith](#notwith) | ||
- [addWith](#addwith) | ||
- [mergeWith](#mergewith) | ||
- [assignWith](#assignwith) | ||
- [callWith](#callwith) | ||
- [Additional objects](#additional-objects) | ||
- [\_\_](#__) | ||
- [Differences from other libraries](#differences-from-other-libraries) | ||
- [lodash](#lodash) | ||
- [ramda](#ramda) | ||
- [Other immutability libraries](#other-immutability-libraries) | ||
- [Browser support](#browser-support) | ||
- [Development](#development) | ||
- [unchanged](#unchanged) | ||
- [Table of contents](#Table-of-contents) | ||
- [Usage](#Usage) | ||
- [Types](#Types) | ||
- [Standard methods](#Standard-methods) | ||
- [get](#get) | ||
- [getOr](#getOr) | ||
- [set](#set) | ||
- [remove](#remove) | ||
- [has](#has) | ||
- [is](#is) | ||
- [not](#not) | ||
- [add](#add) | ||
- [merge](#merge) | ||
- [assign](#assign) | ||
- [call](#call) | ||
- [Transform methods](#Transform-methods) | ||
- [getWith](#getWith) | ||
- [getWithOr](#getWithOr) | ||
- [setWith](#setWith) | ||
- [removeWith](#removeWith) | ||
- [hasWith](#hasWith) | ||
- [isWith](#isWith) | ||
- [notWith](#notWith) | ||
- [addWith](#addWith) | ||
- [mergeWith](#mergeWith) | ||
- [assignWith](#assignWith) | ||
- [callWith](#callWith) | ||
- [Additional objects](#Additional-objects) | ||
- [\_\_](#) | ||
- [Differences from other libraries](#Differences-from-other-libraries) | ||
- [lodash](#lodash) | ||
- [ramda](#ramda) | ||
- [Other immutability libraries](#Other-immutability-libraries) | ||
- [Browser support](#Browser-support) | ||
- [Development](#Development) | ||
@@ -106,3 +108,3 @@ ## Usage | ||
// the callback used in transform methods | ||
type withHandler = (value: any, ...extraParams: any[]) => any; | ||
type WithHandler = (value: any, ...extraParams: any[]) => any; | ||
// the generic object that is computed upon, either an array or object | ||
@@ -118,3 +120,3 @@ interface Unchangeable { | ||
```typescript | ||
const symbolKey: string = (Symbol("key") as unknown) as string; | ||
const symbolKey = (Symbol("key") as unknown) as string; | ||
@@ -1028,3 +1030,3 @@ const object: { [symbolKey]: string } = { | ||
- _lodash_ => _unchanged_ | ||
- _lodash/fp_ => _unchanged_ | ||
- `curry.placeholder` => `__` | ||
@@ -1049,3 +1051,3 @@ - `get` => `get` | ||
Another difference is that the `ramda` methods that clone objects (`assocPath`, for example) only work with objects; arrays are implicitly converted into objects, which can make updating collections challenging. | ||
Another difference is that the `ramda` methods that clone (`assocPath`, for example) only work with objects; arrays are implicitly converted into objects, which can make updating collections challenging. | ||
@@ -1052,0 +1054,0 @@ The last main difference is the way that objects are copied, example: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
257250
27
14
1108
2212
2
Updatedcurriable@^1.3.0
Updatedpathington@^1.1.7