focus on mjs

This commit is contained in:
Yanick Champoux 2023-01-03 14:31:53 -05:00
parent 3dece3fcd5
commit b956e29728
114 changed files with 186 additions and 1279 deletions

View File

@ -6,12 +6,12 @@ vars:
GREETING: Hello, World! GREETING: Hello, World!
tasks: tasks:
test: vitest run
build: build:
deps: [test]
cmds: cmds:
- rm -fr types/ esm/ commonjs/ - rm -fr esm/
- tsc -p tsconfig.json - tsc -p tsconfig.json
- tsc -p tsconfig-cjs.json
- tsc -p tsconfig-types.json
default: default:
cmds: cmds:
- echo "{{.GREETING}}" - echo "{{.GREETING}}"

View File

@ -1,34 +0,0 @@
/**
* Returns a function that always returns the supplied value.
*
* Useful for replacing an object outright rather than merging it.
*
* @function
* @sig a -> (* -> a)
* @memberOf u
* @param {*} value what to return from returned function.
* @return {function} a new function that will always return value.
*
* @example
* var alwaysFour = u.constant(4);
* expect(alwaysFour(32)).toEqual(4);
*
* @example
* var user = {
* name: 'Mitch',
* favorites: {
* band: 'Nirvana',
* movie: 'The Matrix'
* }
* };
*
* var newFavorites = {
* band: 'Coldplay'
* };
*
* var result = u({ favorites: u.constant(newFavorites) }, user);
*
* expect(result).toEqual({ name: 'Mitch', favorites: { band: 'Coldplay' } });
*/
export default function constant<T>(value: T): () => Readonly<T>;
//# sourceMappingURL=constant.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../src/constant.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,qBAG3C"}

View File

@ -1,44 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const freeze_js_1 = __importDefault(require("./freeze.js"));
/**
* Returns a function that always returns the supplied value.
*
* Useful for replacing an object outright rather than merging it.
*
* @function
* @sig a -> (* -> a)
* @memberOf u
* @param {*} value what to return from returned function.
* @return {function} a new function that will always return value.
*
* @example
* var alwaysFour = u.constant(4);
* expect(alwaysFour(32)).toEqual(4);
*
* @example
* var user = {
* name: 'Mitch',
* favorites: {
* band: 'Nirvana',
* movie: 'The Matrix'
* }
* };
*
* var newFavorites = {
* band: 'Coldplay'
* };
*
* var result = u({ favorites: u.constant(newFavorites) }, user);
*
* expect(result).toEqual({ name: 'Mitch', favorites: { band: 'Coldplay' } });
*/
function constant(value) {
const frozen = (0, freeze_js_1.default)(value);
return () => frozen;
}
exports.default = constant;
//# sourceMappingURL=constant.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../src/constant.ts"],"names":[],"mappings":";;;;;AAAA,4DAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAwB,QAAQ,CAAI,KAAQ;IAC1C,MAAM,MAAM,GAAG,IAAA,mBAAM,EAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC;AACtB,CAAC;AAHD,2BAGC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=constant.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"constant.test.d.ts","sourceRoot":"","sources":["../src/constant.test.ts"],"names":[],"mappings":""}

View File

@ -1,18 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const constant_js_1 = __importDefault(require("./constant.js"));
(0, vitest_1.test)("returns what it is given... constantly", () => {
const func = (0, constant_js_1.default)(4);
(0, vitest_1.expect)(func()).to.equal(4);
(0, vitest_1.expect)(func("hi")).to.equal(4);
(0, vitest_1.expect)(func("hi", 8)).to.equal(4);
(0, vitest_1.expect)(func(4)).to.equal(4);
});
(0, vitest_1.test)("freezes the result", () => {
(0, vitest_1.expect)(Object.isFrozen((0, constant_js_1.default)({})())).toBeTruthy();
});
//# sourceMappingURL=constant.test.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"constant.test.js","sourceRoot":"","sources":["../src/constant.test.ts"],"names":[],"mappings":";;;;;AAAA,mCAAgD;AAChD,gEAAqC;AAErC,IAAA,aAAI,EAAC,wCAAwC,EAAE,GAAG,EAAE;IAChD,MAAM,IAAI,GAAQ,IAAA,qBAAQ,EAAC,CAAC,CAAC,CAAC;IAE9B,IAAA,eAAM,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAA,eAAM,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/B,IAAA,eAAM,EAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClC,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,oBAAoB,EAAE,GAAG,EAAE;IAC5B,IAAA,eAAM,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAA,qBAAQ,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;AACzD,CAAC,CAAC,CAAC"}

19
commonjs/freeze.d.ts vendored
View File

@ -1,19 +0,0 @@
/**
* Deeply freeze a plain javascript object.
*
* If `process.env.NODE_ENV === 'production'`, this returns the original object
* without freezing.
*
* Or if `process.env.UPDEEP_MODE === 'dangerously_never_freeze'`, this returns the original object
* without freezing.
*
* If in a browser and built without replacing process, never freeze.
*
* @function
* @sig a -> a
* @param object Object to freeze.
* @return Frozen object, unless in production, then the same object.
*/
declare function freeze<T>(object: T): Readonly<T>;
export default freeze;
//# sourceMappingURL=freeze.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"freeze.d.ts","sourceRoot":"","sources":["../src/freeze.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAkBzC;AAED,eAAe,MAAM,CAAC"}

View File

@ -1,57 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function isFreezable(object) {
if (object === null)
return false;
if (object instanceof RegExp)
return false;
if (object instanceof ArrayBuffer)
return false;
return Array.isArray(object) || typeof object === "object";
}
function needsFreezing(object) {
return isFreezable(object) && !Object.isFrozen(object);
}
function recur(object) {
Object.freeze(object);
Object.keys(object).forEach((key) => {
const value = object[key];
if (needsFreezing(value)) {
recur(value);
}
});
return object;
}
/**
* Deeply freeze a plain javascript object.
*
* If `process.env.NODE_ENV === 'production'`, this returns the original object
* without freezing.
*
* Or if `process.env.UPDEEP_MODE === 'dangerously_never_freeze'`, this returns the original object
* without freezing.
*
* If in a browser and built without replacing process, never freeze.
*
* @function
* @sig a -> a
* @param object Object to freeze.
* @return Frozen object, unless in production, then the same object.
*/
function freeze(object) {
if (typeof process === "undefined") {
return object;
}
if (process.env.NODE_ENV === "production") {
return object;
}
if (process.env.UPDEEP_MODE === "dangerously_never_freeze") {
return object;
}
if (needsFreezing(object)) {
recur(object);
}
return object;
}
exports.default = freeze;
//# sourceMappingURL=freeze.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"freeze.js","sourceRoot":"","sources":["../src/freeze.ts"],"names":[],"mappings":";;AAAA,SAAS,WAAW,CAAC,MAAe;IAClC,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClC,IAAI,MAAM,YAAY,MAAM;QAAE,OAAO,KAAK,CAAC;IAC3C,IAAI,MAAM,YAAY,WAAW;QAAE,OAAO,KAAK,CAAC;IAEhD,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC;AAC7D,CAAC;AAED,SAAS,aAAa,CAAC,MAAe;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,KAAK,CAAC,MAAM;IACnB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE;YACxB,KAAK,CAAC,KAAK,CAAC,CAAC;SACd;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAS,MAAM,CAAI,MAAS;IAC1B,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;QAClC,OAAO,MAAM,CAAC;KACf;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,OAAO,MAAM,CAAC;KACf;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,0BAA0B,EAAE;QAC1D,OAAO,MAAM,CAAC;KACf;IAED,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;QACzB,KAAK,CAAC,MAAM,CAAC,CAAC;KACf;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kBAAe,MAAM,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=freeze.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"freeze.test.d.ts","sourceRoot":"","sources":["../src/freeze.test.ts"],"names":[],"mappings":""}

View File

@ -1,61 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const freeze_js_1 = __importDefault(require("./freeze.js"));
(0, vitest_1.describe)("freeze", () => {
(0, vitest_1.afterEach)(() => {
delete process.env.NODE_ENV;
});
(0, vitest_1.test)("freezes objects", () => {
const object = {};
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object)).to.be.true;
});
(0, vitest_1.test)("freezes nested objects", () => {
const object = { foo: { bar: 3 } };
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object.foo)).to.be.true;
});
(0, vitest_1.test)("freezes nested arrays", () => {
const object = [[0]];
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object)).to.be.true;
(0, vitest_1.expect)(Object.isFrozen(object[0])).to.be.true;
});
(0, vitest_1.test)("ignores functions", () => {
const object = { foo: () => 1 };
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object.foo)).to.be.false;
});
(0, vitest_1.test)("ignores regexps", () => {
const object = { foo: /\d/ };
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object.foo)).to.be.false;
});
(0, vitest_1.test)("does not freeze children if the parent is already frozen", () => {
const object = { foo: {} };
Object.freeze(object);
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object.foo)).to.be.false;
});
(0, vitest_1.test)("does not freeze in production", () => {
process.env.NODE_ENV = "production";
const object = {};
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object)).to.be.false;
});
(0, vitest_1.test)("handles null objects", () => {
const object = { foo: null };
(0, freeze_js_1.default)(object);
(0, vitest_1.expect)(Object.isFrozen(object)).to.be.true;
});
(0, vitest_1.test)("returns the same object", () => {
const object = {};
const result = (0, freeze_js_1.default)(object);
(0, vitest_1.expect)(result).to.equal(object);
});
});
//# sourceMappingURL=freeze.test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eAAM,EAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,sBAAsB,EAAE,GAAG,EAAE;QAChC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QAC7B,IAAA,mBAAM,EAAC,MAAM,CAAC,CAAC;QACf,IAAA,eAAM,EAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,yBAAyB,EAAE,GAAG,EAAE;QACnC,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,IAAA,mBAAM,EAAC,MAAM,CAAC,CAAC;QAC9B,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

7
commonjs/if.d.ts vendored
View File

@ -1,7 +0,0 @@
interface If {
(object: any, predicate: any, trueUpdates: any): unknown;
(predicate: any, trueUpdates: any): (unknown: any) => unknown;
}
declare const _default: If;
export default _default;
//# sourceMappingURL=if.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"if.d.ts","sourceRoot":"","sources":["../src/if.ts"],"names":[],"mappings":"AAKA,UAAU,EAAE;IACV,CAAC,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,GAAG,OAAO,CAAC;IAC1C,CAAC,SAAS,KAAA,EAAE,WAAW,KAAA,GAAG,CAAC,OAAO,KAAA,KAAK,OAAO,CAAC;CAChD;;AAMD,wBAA+B"}

View File

@ -1,13 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const remeda_1 = require("remeda");
const ifElse_js_1 = __importDefault(require("./ifElse.js"));
const wrap_js_1 = __importDefault(require("./wrap.js"));
function _if(object, predicate, trueUpdates) {
return (0, ifElse_js_1.default)(object, predicate, trueUpdates, remeda_1.identity);
}
exports.default = (0, wrap_js_1.default)(_if);
//# sourceMappingURL=if.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"if.js","sourceRoot":"","sources":["../src/if.ts"],"names":[],"mappings":";;;;;AAAA,mCAAkC;AAElC,4DAAiC;AACjC,wDAA6B;AAO7B,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW;IACzC,OAAO,IAAA,mBAAM,EAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,kBAAe,IAAA,iBAAI,EAAC,GAAG,CAAO,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=if.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"if.test.d.ts","sourceRoot":"","sources":["../src/if.test.ts"],"names":[],"mappings":""}

View File

@ -1,32 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const if_js_1 = __importDefault(require("./if.js"));
(0, vitest_1.describe)("if", () => {
(0, vitest_1.test)("does not update if the predicate is false", () => {
const object = { a: 0 };
let result = (0, if_js_1.default)(false, { b: 1 }, object);
(0, vitest_1.expect)(result).to.eql(object);
result = (0, if_js_1.default)(0, false, 1);
(0, vitest_1.expect)(result).to.eql(0);
});
(0, vitest_1.test)("does update if the predicate is true", () => {
const object = { a: 0 };
const result = (0, if_js_1.default)(true, { b: 1 })(object);
(0, vitest_1.expect)(result).to.eql({ a: 0, b: 1 });
});
(0, vitest_1.test)("will use the result of a function passed as a predicate", () => {
const object = { a: 0 };
const aIsThree = (x) => x.a === 3;
const result = (0, if_js_1.default)(aIsThree, { b: 1 }, object);
(0, vitest_1.expect)(result).to.eql({ a: 0 });
});
(0, vitest_1.test)("freezes the result", () => {
(0, vitest_1.expect)(Object.isFrozen((0, if_js_1.default)(true, {})({}))).to.be.true;
(0, vitest_1.expect)(Object.isFrozen((0, if_js_1.default)(false, {})({}))).to.be.true;
});
});
//# sourceMappingURL=if.test.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"if.test.js","sourceRoot":"","sources":["../src/if.test.ts"],"names":[],"mappings":";;;;;AAAA,mCAAgD;AAEhD,oDAA0B;AAE1B,IAAA,iBAAQ,EAAC,IAAI,EAAE,GAAG,EAAE;IAClB,IAAA,aAAI,EAAC,2CAA2C,EAAE,GAAG,EAAE;QACrD,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxB,IAAI,MAAM,GAAG,IAAA,eAAG,EAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC1C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE9B,MAAM,GAAG,IAAA,eAAG,EAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAC1B,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,sCAAsC,EAAE,GAAG,EAAE;QAChD,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,IAAA,eAAG,EAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,yDAAyD,EAAE,GAAG,EAAE;QACnE,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,IAAA,eAAG,EAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAE/C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,oBAAoB,EAAE,GAAG,EAAE;QAC9B,IAAA,eAAM,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAA,eAAG,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACtD,IAAA,eAAM,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAA,eAAG,EAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@ -1,8 +0,0 @@
type Predicate = ((source: any) => boolean) | boolean;
interface IfElse {
(object: any, predicate: Predicate, trueUpdates: any, falseUpdates: any): unknown;
(predicate: Predicate, trueUpdates: any, falseUpdates: any): (unknown: any) => unknown;
}
declare const _default: IfElse;
export default _default;
//# sourceMappingURL=ifElse.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"ifElse.d.ts","sourceRoot":"","sources":["../src/ifElse.ts"],"names":[],"mappings":"AAWA,KAAK,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;AAEtD,UAAU,MAAM;IACd,CAAC,MAAM,KAAA,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,KAAA,EAAE,YAAY,KAAA,GAAG,OAAO,CAAC;IACnE,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,KAAA,EAAE,YAAY,KAAA,GAAG,CAAC,OAAO,KAAA,KAAK,OAAO,CAAC;CACzE;;AAED,wBAA4C"}

View File

@ -1,14 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const update_js_1 = __importDefault(require("./update.js"));
const wrap_js_1 = __importDefault(require("./wrap.js"));
function updateIfElse(object, predicate, trueUpdates, falseUpdates) {
const test = typeof predicate === "function" ? predicate(object) : predicate;
const updates = test ? trueUpdates : falseUpdates;
return (0, update_js_1.default)(object, updates);
}
exports.default = (0, wrap_js_1.default)(updateIfElse);
//# sourceMappingURL=ifElse.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"ifElse.js","sourceRoot":"","sources":["../src/ifElse.ts"],"names":[],"mappings":";;;;;AAAA,4DAAiC;AACjC,wDAA6B;AAE7B,SAAS,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY;IAChE,MAAM,IAAI,GAAG,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7E,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;IAElD,OAAO,IAAA,mBAAM,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AASD,kBAAe,IAAA,iBAAI,EAAC,YAAY,CAAW,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=ifElse.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"ifElse.test.d.ts","sourceRoot":"","sources":["../src/ifElse.test.ts"],"names":[],"mappings":""}

View File

@ -1,43 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const ifElse_js_1 = __importDefault(require("./ifElse.js"));
const if_js_1 = __importDefault(require("./if.js"));
(0, vitest_1.describe)("ifElse", () => {
(0, vitest_1.test)("does updates with the else if the predicate is false", () => {
const object = { a: 0 };
const result = (0, ifElse_js_1.default)(false, { b: 1 }, { b: 2 })(object);
(0, vitest_1.expect)(result).to.eql({ a: 0, b: 2 });
});
(0, vitest_1.test)("updates with the true update if the predicate is true", () => {
const object = { a: 0 };
const result = (0, ifElse_js_1.default)(true, { b: 1 }, { b: 4 })(object);
(0, vitest_1.expect)(result).to.eql({ a: 0, b: 1 });
});
(0, vitest_1.test)("will use the result of a function passed as a predicate", () => {
const object = { a: 0 };
const aIsThree = (x) => x.a === 3;
const result = (0, ifElse_js_1.default)(aIsThree, { b: 1 }, { b: 4 })(object);
(0, vitest_1.expect)(result).to.eql({ a: 0, b: 4 });
});
(0, vitest_1.test)("freezes the result", () => {
(0, vitest_1.expect)(Object.isFrozen((0, ifElse_js_1.default)(true, {}, {})({}))).to.be.true;
(0, vitest_1.expect)(Object.isFrozen((0, ifElse_js_1.default)(false, {}, {})({}))).to.be.true;
});
});
(0, vitest_1.describe)("if", () => {
(0, vitest_1.test)("does updates with the else if the predicate is false", () => {
const object = { a: 0 };
const result = (0, if_js_1.default)(false, { b: 1 })(object);
(0, vitest_1.expect)(result).not.toHaveProperty("b");
});
(0, vitest_1.test)("updates with the true update if the predicate is true", () => {
const object = { a: 0 };
const result = (0, if_js_1.default)(true, { b: 1 })(object);
(0, vitest_1.expect)(result).to.eql({ a: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G,EAAE;QACjE,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,IAAA,eAAG,EAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

3
commonjs/index.d.ts vendored
View File

@ -1,3 +0,0 @@
declare const u: any;
export default u;
//# sourceMappingURL=index.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,CAAC,EAAE,GAAY,CAAC;AAWtB,eAAe,CAAC,CAAC"}

View File

@ -1,46 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const freeze_js_1 = __importDefault(require("./freeze.js"));
const is_js_1 = __importDefault(require("./is.js"));
const if_js_1 = __importDefault(require("./if.js"));
const ifElse_js_1 = __importDefault(require("./ifElse.js"));
const update_js_1 = __importStar(require("./update.js"));
const updateIn_js_1 = __importDefault(require("./updateIn.js"));
const constant_js_1 = __importDefault(require("./constant.js"));
const u = update_js_1.default;
u.constant = constant_js_1.default;
u.if = if_js_1.default;
u.ifElse = ifElse_js_1.default;
u.is = is_js_1.default;
u.freeze = freeze_js_1.default;
u.update = update_js_1.default;
u.updateIn = updateIn_js_1.default;
u.omitted = update_js_1.omitted;
exports.default = u;
//# sourceMappingURL=index.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAiC;AACjC,oDAAyB;AACzB,oDAA0B;AAC1B,4DAAiC;AACjC,yDAA8C;AAC9C,gEAAqC;AACrC,gEAAqC;AAErC,MAAM,CAAC,GAAQ,mBAAM,CAAC;AAEtB,CAAC,CAAC,QAAQ,GAAG,qBAAQ,CAAC;AACtB,CAAC,CAAC,EAAE,GAAG,eAAG,CAAC;AACX,CAAC,CAAC,MAAM,GAAG,mBAAM,CAAC;AAClB,CAAC,CAAC,EAAE,GAAG,eAAE,CAAC;AACV,CAAC,CAAC,MAAM,GAAG,mBAAM,CAAC;AAClB,CAAC,CAAC,MAAM,GAAG,mBAAM,CAAC;AAClB,CAAC,CAAC,QAAQ,GAAG,qBAAQ,CAAC;AACtB,CAAC,CAAC,OAAO,GAAG,mBAAO,CAAC;AAEpB,kBAAe,CAAC,CAAC"}

7
commonjs/is.d.ts vendored
View File

@ -1,7 +0,0 @@
interface Is {
(object: any, path: string | number | (number | string)[], predicate: any): boolean;
(path: string | number | (number | string)[], predicate: any): (object: any) => boolean;
}
declare const _default: Is;
export default _default;
//# sourceMappingURL=is.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAsBA,UAAU,EAAE;IACR,CAAC,MAAM,KAAA,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,KAAA,GAAG,OAAO,CAAC;IAC1E,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,KAAA,GAAG,CAAC,MAAM,KAAA,KAAK,OAAO,CAAC;CACjF;;AAED,wBAA+B"}

View File

@ -1,21 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const splitPath_js_1 = __importDefault(require("./util/splitPath.js"));
const wrap_js_1 = __importDefault(require("./wrap.js"));
function _is(object, path, predicate) {
const parts = (0, splitPath_js_1.default)(path);
for (const part of parts) {
if (typeof object === "undefined")
return false;
object = object[part];
}
if (typeof predicate === "function") {
return predicate(object);
}
return predicate === object;
}
exports.default = (0, wrap_js_1.default)(_is);
//# sourceMappingURL=is.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"is.js","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":";;;;;AAAA,uEAA4C;AAC5C,wDAA6B;AAE7B,SAAS,GAAG,CACR,MAAM,EACN,IAA2C,EAC3C,SAAS;IAET,MAAM,KAAK,GAAG,IAAA,sBAAS,EAAC,IAAI,CAAC,CAAC;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,KAAK,CAAC;QAChD,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;KACzB;IAED,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QACjC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;KAC5B;IAED,OAAO,SAAS,KAAK,MAAM,CAAC;AAChC,CAAC;AAOD,kBAAe,IAAA,iBAAI,EAAC,GAAG,CAAO,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=is.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"is.test.d.ts","sourceRoot":"","sources":["../src/is.test.ts"],"names":[],"mappings":""}

View File

@ -1,52 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const is_js_1 = __importDefault(require("./is.js"));
(0, vitest_1.test)("returns true if path matches a value predicate", () => {
const result = (0, is_js_1.default)({ a: { b: 4 } }, "a.b", 4);
(0, vitest_1.expect)(result).to.be.true;
});
(0, vitest_1.test)("returns true if path matches a function predicate", () => {
const isEven = (x) => x % 2 === 0;
const result = (0, is_js_1.default)("a.b", isEven)({ a: { b: 6 } });
(0, vitest_1.expect)(result).to.be.true;
});
(0, vitest_1.test)("returns false if path matches a value predicate", () => {
const result = (0, is_js_1.default)("a.b", 4)({ a: { b: 5 } });
(0, vitest_1.expect)(result).to.be.false;
});
(0, vitest_1.test)("returns false if path matches a function predicate", () => {
const isEven = (x) => x % 2 === 0;
const result = (0, is_js_1.default)("a.b", isEven)({ a: { b: 7 } });
(0, vitest_1.expect)(result).to.be.false;
});
(0, vitest_1.test)("returns false if the path does not exist", () => {
const result = (0, is_js_1.default)("a.b.c.d", 4)({ a: { b: {} } });
(0, vitest_1.expect)(result).to.be.false;
});
(0, vitest_1.test)("can test for undefined", () => {
const result = (0, is_js_1.default)("a.b.c", undefined)({ a: { b: {} } });
(0, vitest_1.expect)(result).to.be.true;
});
(0, vitest_1.test)("tests the actual object if a blank path is given", () => {
const result = (0, is_js_1.default)(4, "", 4);
(0, vitest_1.expect)(result).toBeTruthy();
});
(0, vitest_1.test)("can use arrays as paths", () => {
const result = (0, is_js_1.default)(["a", "b"], 4)({ a: { b: 4 } });
(0, vitest_1.expect)(result).to.be.true;
});
(0, vitest_1.test)("can include array indexes in paths", () => {
let result = (0, is_js_1.default)("a.1.b", 4)({ a: [{}, { b: 4 }] });
(0, vitest_1.expect)(result).to.be.true;
result = (0, is_js_1.default)(["a", 1, "b"], 4)({ a: [{}, { b: 4 }] });
(0, vitest_1.expect)(result).to.be.true;
});
(0, vitest_1.test)("can be partially applied", () => {
const result = (0, is_js_1.default)("a.b", 4)({ a: { b: 4 } });
(0, vitest_1.expect)(result).to.be.true;
});
//# sourceMappingURL=is.test.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"is.test.js","sourceRoot":"","sources":["../src/is.test.ts"],"names":[],"mappings":";;;;;AAAA,mCAAsC;AACtC,oDAAyB;AAEzB,IAAA,aAAI,EAAC,gDAAgD,EAAE,GAAG,EAAE;IACxD,MAAM,MAAM,GAAG,IAAA,eAAE,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAE7C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,mDAAmD,EAAE,GAAG,EAAE;IAC3D,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,IAAA,eAAE,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAClD,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,iDAAiD,EAAE,GAAG,EAAE;IACzD,MAAM,MAAM,GAAG,IA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C,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC,CAAC,CAAC"}

7
commonjs/map.d.ts vendored
View File

@ -1,7 +0,0 @@
interface Map {
(object: any, iteratee: any): any;
(iteratee: any): (object: any) => any;
}
declare const _default: Map;
export default _default;
//# sourceMappingURL=map.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAuBA,UAAU,GAAG;IACX,CAAC,MAAM,KAAA,EAAE,QAAQ,KAAA,GAAG,GAAG,CAAC;IACxB,CAAC,QAAQ,KAAA,GAAG,CAAC,MAAM,KAAA,KAAK,GAAG,CAAC;CAC7B;;AAED,wBAAgC"}

View File

@ -1,24 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const remeda_1 = require("remeda");
const update_js_1 = __importDefault(require("./update.js"));
const wrap_js_1 = __importDefault(require("./wrap.js"));
function shallowEqual(object, otherObject) {
for (const k in otherObject) {
if (otherObject[k] !== object[k])
return false;
}
return true;
}
function map(object, iteratee) {
const updater = typeof iteratee === "function" ? iteratee : (0, update_js_1.default)(iteratee);
const mapper = Array.isArray(object) ? remeda_1.map.indexed : remeda_1.mapValues;
const newObject = mapper(object, updater);
const equal = shallowEqual(object, newObject);
return equal ? object : newObject;
}
exports.default = (0, wrap_js_1.default)(map);
//# sourceMappingURL=map.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":";;;;;AAAA,mCAAgD;AAEhD,4DAAiC;AACjC,wDAA6B;AAE7B,SAAS,YAAY,CAAC,MAAM,EAAE,WAAW;IACvC,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE;QAC3B,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;KAChD;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,GAAG,CAAC,MAAM,EAAE,QAAQ;IAC3B,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,mBAAM,EAAC,QAAQ,CAAC,CAAC;IAE7E,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAI,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAS,CAAC;IAEhE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAE9C,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACpC,CAAC;AAOD,kBAAe,IAAA,iBAAI,EAAC,GAAG,CAAQ,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=map.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"map.test.d.ts","sourceRoot":"","sources":["../src/map.test.ts"],"names":[],"mappings":""}

View File

@ -1,51 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const map_js_1 = __importDefault(require("./map.js"));
(0, vitest_1.describe)("map", () => {
(0, vitest_1.test)("applies updates to each item in an array", () => {
const object = [0, 1, 2];
const inc = (x) => x + 1;
const result = (0, map_js_1.default)(object, inc);
(0, vitest_1.expect)(result).to.eql([1, 2, 3]);
});
(0, vitest_1.test)("applies updates to each value in an object", () => {
const object = { a: 0, b: 1, c: 2 };
const inc = (x) => x + 1;
const result = (0, map_js_1.default)(inc)(object);
(0, vitest_1.expect)(result).to.eql({ a: 1, b: 2, c: 3 });
});
(0, vitest_1.test)("can update with a regular updates object", () => {
const object = [{ a: 0 }, { a: 0 }];
const result = (0, map_js_1.default)({ a: 1 })(object);
(0, vitest_1.expect)(result).to.eql([{ a: 1 }, { a: 1 }]);
});
(0, vitest_1.test)("returns the same object if no updates are made", () => {
const array = [0, 1];
const ident = (x) => x;
let result = (0, map_js_1.default)(ident)(array);
(0, vitest_1.expect)(result).to.equal(array);
const object = { a: 0 };
result = (0, map_js_1.default)(ident)(object);
(0, vitest_1.expect)(result).to.equal(object);
});
(0, vitest_1.test)("passes the key or index as the second parameter to the iteratee", () => {
const object = {
a: { x: 0 },
b: [3, 3],
};
const setToKey = (_, key) => key;
const result = (0, map_js_1.default)(object, (0, map_js_1.default)(setToKey));
(0, vitest_1.expect)(result).to.eql({
a: { x: "x" },
b: [0, 1],
});
});
(0, vitest_1.test)("freezes the result", () => {
(0, vitest_1.expect)(Object.isFrozen((0, map_js_1.default)({}, {}))).to.be.true;
});
});
//# sourceMappingURL=map.test.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"map.test.js","sourceRoot":"","sources":["../src/map.test.ts"],"names":[],"mappings":";;;;;AAAA,mCAAgD;AAChD,sDAA2B;AAE3B,IAAA,iBAAQ,EAAC,KAAK,EAAE,GAAG,EAAE;IACnB,IAAA,aAAI,EAAC,0CAA0C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACzB,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,IAAA,gBAAG,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAEhC,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,C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
interface Update {
(object: any, func: any): any;
(func: any): (object: any) => any;
}
declare const _default: Update;
export default _default;
//# sourceMappingURL=update.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO;;EAAyB,CAAC;AAkG9C,UAAU,MAAM;IACd,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA,GAAG,GAAG,CAAC;IACpB,CAAC,IAAI,KAAA,GAAG,CAAC,MAAM,KAAA,KAAK,GAAG,CAAC;CACzB;;AAED,wBAAsC"}

View File

@ -1,78 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.omitted = void 0;
const wrap_js_1 = __importDefault(require("./wrap.js"));
const constant_js_1 = __importDefault(require("./constant.js"));
const remeda_1 = require("remeda");
const innerOmitted = { __omitted: true };
exports.omitted = (0, constant_js_1.default)(innerOmitted);
function isEmpty(object) {
return !Object.keys(object).length;
}
function reduce(object, callback, initialValue) {
return Object.keys(object).reduce((acc, key) => callback(acc, object[key], key), initialValue);
}
function resolveUpdates(updates, object) {
return reduce(updates, (acc, value, key) => {
let updatedValue = value;
if (!Array.isArray(value) &&
value !== null &&
typeof value === "object") {
updatedValue = update(object[key], value); // eslint-disable-line no-use-before-define
}
else if (typeof value === "function") {
updatedValue = value(object[key]);
}
if (object[key] !== updatedValue) {
acc[key] = updatedValue; // eslint-disable-line no-param-reassign
}
return acc;
}, {});
}
function updateArray(updates, object) {
const newArray = [...object];
Object.keys(updates).forEach((key) => {
newArray[key] = updates[key];
});
return newArray;
}
const isPlainObject = (value) => (value === null || value === void 0 ? void 0 : value.constructor) === Object;
/**
* Recursively update an object or array.
*
* Can update with values:
* update({ foo: 3 }, { foo: 1, bar: 2 });
* // => { foo: 3, bar: 2 }
*
* Or with a function:
* update({ foo: x => (x + 1) }, { foo: 2 });
* // => { foo: 3 }
*
* @function
* @name update
* @param {Object|Function} updates
* @param {Object|Array} object to update
* @return {Object|Array} new object with modifications
*/
function update(object, updates) {
if (typeof updates === "function") {
return updates(object);
}
if (!isPlainObject(updates)) {
return updates;
}
const defaultedObject = typeof object === "undefined" || object === null ? {} : object;
const resolvedUpdates = resolveUpdates(updates, defaultedObject);
if (isEmpty(resolvedUpdates)) {
return defaultedObject;
}
if (Array.isArray(defaultedObject)) {
return updateArray(resolvedUpdates, defaultedObject).filter((value) => value !== innerOmitted);
}
return (0, remeda_1.omitBy)(Object.assign(Object.assign({}, defaultedObject), resolvedUpdates), (value) => value === innerOmitted);
}
exports.default = (0, wrap_js_1.default)(update);
//# sourceMappingURL=update.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"update.js","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA6B;AAC7B,gEAAqC;AAErC,mCAA0C;AAE1C,MAAM,YAAY,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC5B,QAAA,OAAO,GAAG,IAAA,qBAAQ,EAAC,YAAY,CAAC,CAAC;AAE9C,SAAS,OAAO,CAAC,MAAM;IACrB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;AACrC,CAAC;AAED,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY;IAC5C,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAC/B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAC7C,YAAY,CACb,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAAO,EAAE,MAAM;IACrC,OAAO,MAAM,CACX,OAAO,EACP,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAClB,IAAI,YAAY,G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AO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAEjE,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAEjE,IAAI,OAAO,CAAC,eAAe,CAAC,EAAE;QAC5B,OAAO,eAAe,CAAC;KACxB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAClC,OAAO,WAAW,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,MAAM,CACzD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,YAAY,CAClC,CAAC;KACH;IAED,OAAO,IAAA,eAAM,kCACN,eAAe,GAAK,eAAe,GACxC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,YAAY,CAClC,CAAC;AACJ,CAAC;AAOD,kBAAe,IAAA,iBAAI,EAAC,MAAM,CAAW,CAAC"}

View File

@ -1,7 +0,0 @@
interface UpdateIn {
(object: any, path: any, value: any): any;
(path: any, value: any): (object: any) => any;
}
declare const _default: UpdateIn;
export default _default;
//# sourceMappingURL=updateIn.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"updateIn.d.ts","sourceRoot":"","sources":["../src/updateIn.ts"],"names":[],"mappings":"AA4BA,UAAU,QAAQ;IAChB,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA,EAAE,KAAK,KAAA,GAAG,GAAG,CAAC;IAC3B,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA,GAAG,CAAC,MAAM,KAAA,KAAK,GAAG,CAAC;CAChC;;AAED,wBAA0C"}

View File

@ -1,26 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const update_js_1 = __importDefault(require("./update.js"));
const splitPath_js_1 = __importDefault(require("./util/splitPath.js"));
const wrap_js_1 = __importDefault(require("./wrap.js"));
const map_js_1 = __importDefault(require("./map.js"));
const wildcard = "*";
function reducePath(acc, key) {
if (key === wildcard) {
return (value) => Object.prototype.hasOwnProperty.call(value, wildcard)
? // If we actually have wildcard as a property, update that
(0, update_js_1.default)(value, { [wildcard]: acc })
: // Otherwise map over all properties
(0, map_js_1.default)(value, acc);
}
return { [key]: acc };
}
function updateIn(object, path, value) {
const updates = (0, splitPath_js_1.default)(path).reduceRight(reducePath, value);
return (0, update_js_1.default)(object, updates);
}
exports.default = (0, wrap_js_1.default)(updateIn);
//# sourceMappingURL=updateIn.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"updateIn.js","sourceRoot":"","sources":["../src/updateIn.ts"],"names":[],"mappings":";;;;;AAEA,4DAAiC;AACjC,uEAA4C;AAC5C,wDAA6B;AAC7B,sDAA2B;AAE3B,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG;IAC1B,IAAI,GAAG,KAAK,QAAQ,EAAE;QACpB,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;YACnD,CAAC,CAAC,0DAA0D;gBAC1D,IAAA,mBAAM,EAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;YACpC,CAAC,CAAC,oCAAoC;gBACpC,IAAA,gBAAG,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KACvB;IAED,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;AACxB,CAAC;AAED,SAAS,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK;IACnC,MAAM,OAAO,GAAG,IAAA,sBAAS,EAAC,IAAI,CAAC,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAE/D,OAAO,IAAA,mBAAM,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAOD,kBAAe,IAAA,iBAAI,EAAC,QAAQ,CAAa,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=updateIn.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"updateIn.test.d.ts","sourceRoot":"","sources":["../src/updateIn.test.ts"],"names":[],"mappings":""}

View File

@ -1,57 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const updateIn_js_1 = __importDefault(require("./updateIn.js"));
(0, vitest_1.describe)("updateIn", () => {
(0, vitest_1.test)("can update a single path described with a string", () => {
const object = { a: { b: 0 } };
const result = (0, updateIn_js_1.default)("a.b", 3)(object);
(0, vitest_1.expect)(result).to.eql({ a: { b: 3 } });
});
(0, vitest_1.test)("can update a single path described with a string with a function", () => {
const inc = (x) => x + 1;
const object = { a: { b: 0 } };
const result = (0, updateIn_js_1.default)("a.b", inc)(object);
(0, vitest_1.expect)(result).to.eql({ a: { b: 1 } });
});
(0, vitest_1.test)("can update a single path described with an array", () => {
const object = { a: { b: 0 } };
const result = (0, updateIn_js_1.default)(["a", "b"], 3)(object);
(0, vitest_1.expect)(result).to.eql({ a: { b: 3 } });
});
(0, vitest_1.test)("can update arrays", () => {
const object = { a: [0, 0, 0] };
const result = (0, updateIn_js_1.default)("a.1", 3)(object);
(0, vitest_1.expect)(result).to.eql({ a: [0, 3, 0] });
});
(0, vitest_1.test)("can be partially applied", () => {
const object = { a: { b: 0 } };
const result = (0, updateIn_js_1.default)("a.b", 3)(object);
(0, vitest_1.expect)(result).to.eql({ a: { b: 3 } });
});
(0, vitest_1.test)("replaces the object outright if the path is empty", () => {
const object = {};
const result = (0, updateIn_js_1.default)("", 3)(object);
(0, vitest_1.expect)(result).to.equal(3);
});
(0, vitest_1.test)("freezes the result", () => {
(0, vitest_1.expect)(Object.isFrozen((0, updateIn_js_1.default)("a", 0)({}))).to.be.true;
});
(0, vitest_1.test)("can multiple elements of an array with *", () => {
let object = { a: [{ b: 0 }, { b: 1 }, { b: 2 }] };
let result = (0, updateIn_js_1.default)("a.*.b", (x) => x + 1)(object);
(0, vitest_1.expect)(result).to.eql({ a: [{ b: 1 }, { b: 2 }, { b: 3 }] });
object = { a: [0, 1, 2] };
result = (0, updateIn_js_1.default)(["a", "*"], (x) => x + 1)(object);
(0, vitest_1.expect)(result).to.eql({ a: [1, 2, 3] });
});
(0, vitest_1.test)("can update properties named *", () => {
const object = { "*": 1, x: 1 };
const result = (0, updateIn_js_1.default)("*", (x) => x + 1)(object);
(0, vitest_1.expect)(result).to.eql({ "*": 2, x: 1 });
});
});
//# sourceMappingURL=updateIn.test.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"updateIn.test.js","sourceRoot":"","sources":["../src/updateIn.test.ts"],"names":[],"mappings":";;;;;AAAA,mCAAgD;AAChD,gEAAqC;AAErC,IAAA,iBAAQ,EAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAA,aAAI,EAAC,kDAAkD,EAAE,GAAG,EAAE;QAC5D,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAA,qBAAQ,EAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,kEAAkE,EAAE,GAAG,EAAE;QAC5E,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,E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C,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAE7D,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAC1B,MAAM,GAAG,IAAA,qBAAQ,EAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpD,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,+BAA+B,EAAE,GAAG,EAAE;QACzC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,IAAA,qBAAQ,EAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACnD,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=updeep.bench.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"updeep.bench.d.ts","sourceRoot":"","sources":["../src/updeep.bench.ts"],"names":[],"mappings":""}

View File

@ -1,15 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const updeep_1 = __importDefault(require("updeep"));
const index_js_1 = __importDefault(require("./index.js"));
const vitest_1 = require("vitest");
(0, vitest_1.bench)("original, simple update", () => {
updeep_1.default({ a: 1 })({ a: 2, b: 3 });
});
(0, vitest_1.bench)("contender, simple update", () => {
(0, index_js_1.default)({ a: 1 })({ a: 2, b: 3 });
});
//# sourceMappingURL=updeep.bench.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"updeep.bench.js","sourceRoot":"","sources":["../src/updeep.bench.ts"],"names":[],"mappings":";;;;;AAAA,oDAA8B;AAC9B,0DAAmC;AAEnC,mCAA+B;AAE/B,IAAA,cAAK,EAAC,yBAAyB,EAAE,GAAG,EAAE;IACnC,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,IAAA,cAAK,EAAC,0BAA0B,EAAE,GAAG,EAAE;IACrC,IAAA,kBAAS,EAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=updeep.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"updeep.test.d.ts","sourceRoot":"","sources":["../src/updeep.test.ts"],"names":[],"mappings":""}

View File

@ -1,113 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const index_js_1 = __importDefault(require("./index.js"));
(0, vitest_1.it)("does not change anything if no updates are specified", () => {
const object = { foo: 3, bar: [7, 5] };
const result = (0, index_js_1.default)(object, {});
(0, vitest_1.expect)(result).to.equal(object);
});
(0, vitest_1.it)("can update with fixed values", () => {
const object = { foo: 3, bar: [7, 5] };
const result = (0, index_js_1.default)(object, { foo: 4 });
(0, vitest_1.expect)(result).to.deep.equal({ foo: 4, bar: [7, 5] });
});
(0, vitest_1.it)("returns the same instance if an update doesn't make changes", () => {
const object = { foo: 3 };
const result = (0, index_js_1.default)({ foo: 3 })(object);
(0, vitest_1.expect)(result).to.equal(object);
});
(0, vitest_1.it)("can update a nested structure", () => {
const object = { foo: { bar: 7, bam: 3 }, baz: 32 };
const result = (0, index_js_1.default)({ foo: { bar: 8 } })(object);
(0, vitest_1.expect)(result).to.deep.equal({ foo: { bar: 8, bam: 3 }, baz: 32 });
});
(0, vitest_1.it)("can update arrays", () => {
const object = [1, 2, 3];
const result = (0, index_js_1.default)({ 1: 7 })(object);
(0, vitest_1.expect)(result).to.deep.equal([1, 7, 3]);
});
(0, vitest_1.it)("replaces the object outright if updates are a constant", () => {
(0, vitest_1.expect)((0, index_js_1.default)(3)({})).to.equal(3);
(0, vitest_1.expect)((0, index_js_1.default)(null)({})).to.be.null;
});
(0, vitest_1.it)("can add an element to an array", () => {
const object = [];
const result = (0, index_js_1.default)({ 0: 3 })(object);
(0, vitest_1.expect)(result).to.eql([3]);
});
(0, vitest_1.it)("can update nested arrays", () => {
const object = { foo: [1, 2, 3], bar: 9 };
const result = (0, index_js_1.default)({ foo: { 1: 7 } })(object);
(0, vitest_1.expect)(result).to.deep.equal({ foo: [1, 7, 3], bar: 9 });
});
(0, vitest_1.it)("can use functions to update values", () => {
const inc = (i) => i + 1;
const object = { foo: 3, bar: 4, baz: 7 };
const result = (0, index_js_1.default)({ foo: inc, bar: inc })(object);
(0, vitest_1.expect)(result).to.deep.equal({ foo: 4, bar: 5, baz: 7 });
});
(0, vitest_1.it)("can be partially applied", () => {
const inc = (i) => i + 1;
const object = { foo: 3 };
const incFoo = (0, index_js_1.default)({ foo: inc });
const result = incFoo(object);
(0, vitest_1.expect)(result).to.deep.equal({ foo: 4 });
});
(0, vitest_1.it)("can update if the value is an array", () => {
const object = {};
const result = (0, index_js_1.default)({ foo: [0, 1] })(object);
(0, vitest_1.expect)(result).to.deep.equal({ foo: [0, 1] });
});
(0, vitest_1.it)("can update when original object is undefined", () => {
const result = (0, index_js_1.default)({ foo: [0, 1] })(undefined);
(0, vitest_1.expect)(result).to.deep.equal({ foo: [0, 1] });
});
(0, vitest_1.it)("can take a function as the updater", () => {
const result = (0, index_js_1.default)((i) => i + 1)(7);
(0, vitest_1.expect)(result).to.eql(8);
});
(0, vitest_1.it)("deeply freezes the result", () => {
const result = (0, index_js_1.default)({ foo: { bar: 3 } }, { foo: { bar: 0 } });
(0, vitest_1.expect)(Object.isFrozen(result)).to.be.true;
(0, vitest_1.expect)(Object.isFrozen(result.foo)).to.be.true;
});
(0, vitest_1.it)("assigns null values", () => {
(0, vitest_1.expect)((0, index_js_1.default)({ isNull: null }, {})).to.eql({ isNull: null });
});
(0, vitest_1.it)("defaults to an empty object when null or undefined", () => {
let result = (0, index_js_1.default)({ a: { b: 0 } })({ a: null });
(0, vitest_1.expect)(result).to.eql({ a: { b: 0 } });
result = (0, index_js_1.default)({ a: { b: 0 } })({ a: undefined });
(0, vitest_1.expect)(result).to.eql({ a: { b: 0 } });
result = (0, index_js_1.default)({ a: { b: 0 } })({});
(0, vitest_1.expect)(result).to.eql({ a: { b: 0 } });
});
(0, vitest_1.it)("preserves empty objects when empty updates are specified", () => {
const result = (0, index_js_1.default)({ a: {} })({});
(0, vitest_1.expect)(result).to.eql({ a: {} });
});
(0, vitest_1.it)("works with date objects", () => {
const date = new Date();
const result = (0, index_js_1.default)({ created: date })({});
(0, vitest_1.expect)(result).toEqual({ created: date });
});
const expectU = (update, orig, expected) => (0, vitest_1.expect)(update(orig)).to.eql(expected);
(0, vitest_1.describe)("u.omitted", () => {
(0, vitest_1.it)("omit properties via u.omitted", () => {
expectU((0, index_js_1.default)({ a: index_js_1.default.omitted, b: (i) => i + 1 }), { a: 1, b: 2 }, { b: 3 });
});
(0, vitest_1.it)("omit array and object properties", () => {
expectU((0, index_js_1.default)({ a: index_js_1.default.omitted, b: "stuff", c: index_js_1.default.omitted }), { a: [1, 2, 3], b: "orig", c: { z: "bar" } }, { b: "stuff" });
});
(0, vitest_1.it)("deep omit", () => {
expectU((0, index_js_1.default)({ a: { b: index_js_1.default.omitted, c: "stuff" } }), { a: { b: "foo", z: "bar" } }, { a: { z: "bar", c: "stuff" } });
});
(0, vitest_1.it)("omitting an array item filters it out", () => {
expectU((0, index_js_1.default)({ 1: index_js_1.default.omitted }), ["a", "b", "c"], ["a", "c"]);
});
});
//# sourceMappingURL=updeep.test.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
export function curry1(fn: any): (a: any, ...args: any[]) => any;
export function curry2(fn: any): (a: any, b: any, ...args: any[]) => any;
export function curry3(fn: any): (a: any, b: any, c: any, ...args: any[]) => any;
export function curry4(fn: any): (a: any, b: any, c: any, d: any, ...args: any[]) => any;
export default function curry(fn: any, length?: any): any;
export const _: "@@updeep/placeholder";
//# sourceMappingURL=curry.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"curry.d.ts","sourceRoot":"","sources":["../../src/util/curry.js"],"names":[],"mappings":"AAcA,iEAQC;AAED,yEAmBC;AAED,iFA6BC;AAED,yFA6CC;AAED,0DAEC;AA5HD,uCAAuC"}

View File

@ -1,123 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.curry4 = exports.curry3 = exports.curry2 = exports.curry1 = exports._ = void 0;
/* eslint no-shadow:0, no-param-reassign:0 prefer-rest-params:0 */
exports._ = '@@updeep/placeholder';
function countArguments(args, max) {
let n = args.length;
if (n > max)
n = max;
while (args[n - 1] === exports._) {
n -= 1;
}
return n;
}
function curry1(fn) {
return function curried(a, ...args) {
const [b, c] = args;
const n = countArguments(arguments);
if (n >= 1)
return fn(a, b, c);
return curried;
};
}
exports.curry1 = curry1;
function curry2(fn) {
return function curried(a, b, ...args) {
const [c, d] = args;
const n = countArguments(arguments, 2);
if (b === exports._ || c === exports._ || d === exports._) {
throw new Error('Can only use placeholder on first argument of this function.');
}
if (n >= 2) {
if (a === exports._)
return curry1((a, c, d) => fn(a, b, c, d));
return fn(a, b, c, d);
}
if (n === 1)
return curry1((b, c, d) => fn(a, b, c, d));
return curried;
};
}
exports.curry2 = curry2;
function curry3(fn) {
return function curried(a, b, c, ...args) {
const [d, e] = args;
const n = countArguments(arguments, 3);
if (c === exports._ || d === exports._ || e === exports._) {
throw new Error('Can only use placeholder on first or second argument of this function.');
}
if (n >= 3) {
if (a === exports._) {
if (b === exports._)
return curry2((a, b, d, e) => fn(a, b, c, d, e));
return curry1((a, d, e) => fn(a, b, c, d, e));
}
if (b === exports._)
return curry1((b, d, e) => fn(a, b, c, d, e));
return fn(a, b, c, d, e);
}
if (n === 2) {
if (a === exports._)
return curry2((a, c, d, e) => fn(a, b, c, d, e));
return curry1((c, d, e) => fn(a, b, c, d, e));
}
if (n === 1)
return curry2((b, c, d, e) => fn(a, b, c, d, e));
return curried;
};
}
exports.curry3 = curry3;
function curry4(fn) {
return function curried(a, b, c, d, ...args) {
const [e, f] = args;
const n = countArguments(arguments, 4);
if (d === exports._ || e === exports._ || f === exports._) {
throw new Error('Can only use placeholder on first, second or third argument of this function.');
}
if (n >= 4) {
if (a === exports._) {
if (b === exports._) {
if (c === exports._)
return curry3((a, b, c, e, f) => fn(a, b, c, d, e, f));
return curry2((a, b, e, f) => fn(a, b, c, d, e, f));
}
if (c === exports._)
return curry2((a, c, e, f) => fn(a, b, c, d, e, f));
return curry1((a, e, f) => fn(a, b, c, d, e, f));
}
if (b === exports._) {
if (c === exports._)
return curry2((b, c, e, f) => fn(a, b, c, d, e, f));
return curry1((b, e, f) => fn(a, b, c, d, e, f));
}
if (c === exports._)
return curry1((c, e, f) => fn(a, b, c, d, e, f));
return fn(a, b, c, d, e, f);
}
if (n === 3) {
if (a === exports._) {
if (b === exports._)
return curry3((a, b, d, e, f) => fn(a, b, c, d, e, f));
return curry2((a, d, e, f) => fn(a, b, c, d, e, f));
}
if (b === exports._)
return curry2((b, d, e, f) => fn(a, b, c, d, e, f));
return curry1((d, e, f) => fn(a, b, c, d, e, f));
}
if (n === 2) {
if (a === exports._)
return curry3((a, c, d, e, f) => fn(a, b, c, d, e, f));
return curry2((c, d, e, f) => fn(a, b, c, d, e, f));
}
if (n === 1)
return curry3((b, c, d, e, f) => fn(a, b, c, d, e, f));
return curried;
};
}
exports.curry4 = curry4;
function curry(fn, length = fn.length) {
return [fn, curry1, curry2, curry3, curry4][length](fn);
}
exports.default = curry;
//# sourceMappingURL=curry.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
export default function splitPath(path: string | number | (number | string)[]): (string | number)[];
//# sourceMappingURL=splitPath.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"splitPath.d.ts","sourceRoot":"","sources":["../../src/util/splitPath.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,uBAM5E"}

View File

@ -1,11 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function splitPath(path) {
if (typeof path === "number")
path = new String(path);
return Array.isArray(path)
? path
: path.split(".").filter((x) => x !== "");
}
exports.default = splitPath;
//# sourceMappingURL=splitPath.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"splitPath.js","sourceRoot":"","sources":["../../src/util/splitPath.ts"],"names":[],"mappings":";;AAAA,SAAwB,SAAS,CAAC,IAA2C;IAC3E,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAQ,CAAC;IAE7D,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACxB,CAAC,CAAC,IAAI;QACN,CAAC,CAAE,IAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC1D,CAAC;AAND,4BAMC"}

View File

@ -1,2 +0,0 @@
export {};
//# sourceMappingURL=splitPath.test.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"splitPath.test.d.ts","sourceRoot":"","sources":["../../src/util/splitPath.test.ts"],"names":[],"mappings":""}

View File

@ -1,23 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const splitPath_js_1 = __importDefault(require("./splitPath.js"));
(0, vitest_1.it)("treats a number as a single step path", () => {
const path = 1;
const result = (0, splitPath_js_1.default)(path);
(0, vitest_1.expect)(result).to.deep.equal(["1"]);
});
(0, vitest_1.it)("handles arrays", () => {
const path = ["foo", "bar", "x"];
const result = (0, splitPath_js_1.default)(path);
(0, vitest_1.expect)(result).to.equal(path);
});
(0, vitest_1.it)("handles strings separated by dots", () => {
const path = "bar.0.y";
const result = (0, splitPath_js_1.default)(path);
(0, vitest_1.expect)(result).to.deep.equal(["bar", "0", "y"]);
});
//# sourceMappingURL=splitPath.test.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"splitPath.test.js","sourceRoot":"","sources":["../../src/util/splitPath.test.ts"],"names":[],"mappings":";;;;;AAAA,mCAAoC;AACpC,kEAAuC;AAEvC,IAAA,WAAE,EAAC,uCAAuC,EAAE,GAAG,EAAE;IAC/C,MAAM,IAAI,GAAG,CAAC,CAAC;IACf,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAC,IAAI,CAAC,CAAC;IAC/B,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC;AAEH,IAAA,WAAE,EAAC,gBAAgB,EAAE,GAAG,EAAE;IACxB,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAC,IAAI,CAAC,CAAC;IAC/B,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAEH,IAAA,WAAE,EAAC,mCAAmC,EAAE,GAAG,EAAE;IAC3C,MAAM,IAAI,GAAG,SAAS,CAAC;IACvB,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAC,IAAI,CAAC,CAAC;IAC/B,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC,CAAC"}

3
commonjs/wrap.d.ts vendored
View File

@ -1,3 +0,0 @@
declare const wrap: (fn: any) => (...args: any[]) => Readonly<any>;
export default wrap;
//# sourceMappingURL=wrap.d.ts.map

View File

@ -1 +0,0 @@
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../src/wrap.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,IAAI,gDAWP,CAAC;AAEJ,eAAe,IAAI,CAAC"}

View File

@ -1,18 +0,0 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const freeze_js_1 = __importDefault(require("./freeze.js"));
const wrap = (fn) => (...args) => {
const diff = fn.length - args.length;
if (diff === 0) {
return (0, freeze_js_1.default)(fn(...args));
}
if (diff === 1) {
return (data) => (0, freeze_js_1.default)(fn(data, ...args));
}
throw new Error("Wrong number of arguments");
};
exports.default = wrap;
//# sourceMappingURL=wrap.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../src/wrap.ts"],"names":[],"mappings":";;;;;AAAA,4DAAiC;AAGjC,MAAM,IAAI,GACR,CAAC,EAAE,EAAE,EAAE,CACP,CAAC,GAAG,IAAI,EAAE,EAAE;IACV,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,IAAI,IAAI,KAAK,CAAC,EAAE;QACd,OAAO,IAAA,mBAAM,EAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;KAC5B;IACD,IAAI,IAAI,KAAK,CAAC,EAAE;QACd,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,mBAAM,EAAC,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;KAC5C;IACD,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEJ,kBAAe,IAAI,CAAC"}

2
esm/if.d.ts vendored
View File

@ -1,4 +1,4 @@
interface If { export interface If {
(object: any, predicate: any, trueUpdates: any): unknown; (object: any, predicate: any, trueUpdates: any): unknown;
(predicate: any, trueUpdates: any): (unknown: any) => unknown; (predicate: any, trueUpdates: any): (unknown: any) => unknown;
} }

View File

@ -1 +1 @@
{"version":3,"file":"if.d.ts","sourceRoot":"","sources":["../src/if.ts"],"names":[],"mappings":"AAKA,UAAU,EAAE;IACV,CAAC,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,GAAG,OAAO,CAAC;IAC1C,CAAC,SAAS,KAAA,EAAE,WAAW,KAAA,GAAG,CAAC,OAAO,KAAA,KAAK,OAAO,CAAC;CAChD;;AAMD,wBAA+B"} {"version":3,"file":"if.d.ts","sourceRoot":"","sources":["../src/if.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,EAAE;IACjB,CAAC,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,GAAG,OAAO,CAAC;IAC1C,CAAC,SAAS,KAAA,EAAE,WAAW,KAAA,GAAG,CAAC,OAAO,KAAA,KAAK,OAAO,CAAC;CAChD;;AAMD,wBAA+B"}

2
esm/ifElse.d.ts vendored
View File

@ -1,5 +1,5 @@
type Predicate = ((source: any) => boolean) | boolean; type Predicate = ((source: any) => boolean) | boolean;
interface IfElse { export interface IfElse {
(object: any, predicate: Predicate, trueUpdates: any, falseUpdates: any): unknown; (object: any, predicate: Predicate, trueUpdates: any, falseUpdates: any): unknown;
(predicate: Predicate, trueUpdates: any, falseUpdates: any): (unknown: any) => unknown; (predicate: Predicate, trueUpdates: any, falseUpdates: any): (unknown: any) => unknown;
} }

View File

@ -1 +1 @@
{"version":3,"file":"ifElse.d.ts","sourceRoot":"","sources":["../src/ifElse.ts"],"names":[],"mappings":"AAWA,KAAK,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;AAEtD,UAAU,MAAM;IACd,CAAC,MAAM,KAAA,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,KAAA,EAAE,YAAY,KAAA,GAAG,OAAO,CAAC;IACnE,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,KAAA,EAAE,YAAY,KAAA,GAAG,CAAC,OAAO,KAAA,KAAK,OAAO,CAAC;CACzE;;AAED,wBAA4C"} {"version":3,"file":"ifElse.d.ts","sourceRoot":"","sources":["../src/ifElse.ts"],"names":[],"mappings":"AAWA,KAAK,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;AAEtD,MAAM,WAAW,MAAM;IACrB,CAAC,MAAM,KAAA,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,KAAA,EAAE,YAAY,KAAA,GAAG,OAAO,CAAC;IACnE,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,KAAA,EAAE,YAAY,KAAA,GAAG,CAAC,OAAO,KAAA,KAAK,OAAO,CAAC;CACzE;;AAED,wBAA4C"}

17
esm/index.d.ts vendored
View File

@ -1,3 +1,16 @@
declare const u: any; import freeze from "./freeze.js";
export default u; import constant from "./constant.js";
declare const _default: import("./update.js").Update & {
constant: typeof constant;
if: import("./if.js").If;
ifElse: import("./ifElse.js").IfElse;
is: import("./is.js").Is;
freeze: typeof freeze;
update: import("./update.js").Update;
updateIn: import("./updateIn.js").UpdateIn;
omitted: () => Readonly<{
__omitted: boolean;
}>;
};
export default _default;
//# sourceMappingURL=index.d.ts.map //# sourceMappingURL=index.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,CAAC,EAAE,GAAY,CAAC;AAWtB,eAAe,CAAC,CAAC"} {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAMjC,OAAO,QAAQ,MAAM,eAAe,CAAC;;;;;;;;;;;;;AAiBrC,wBAA0D"}

View File

@ -5,14 +5,17 @@ import ifElse from "./ifElse.js";
import update, { omitted } from "./update.js"; import update, { omitted } from "./update.js";
import updateIn from "./updateIn.js"; import updateIn from "./updateIn.js";
import constant from "./constant.js"; import constant from "./constant.js";
const u = update; const functions = {
u.constant = constant; constant,
u.if = _if; if: _if,
u.ifElse = ifElse; ifElse,
u.is = is; is,
u.freeze = freeze; freeze,
u.update = update; update,
u.updateIn = updateIn; updateIn,
u.omitted = omitted; omitted,
export default u; };
const merged = update;
Object.entries(functions).forEach(([k, v]) => (merged[k] = v));
export default merged;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,SAAS,CAAC;AAC1B,OAAO,MAAM,MAAM,aAAa,CA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AE/D,eAAe,MAA0C,CAAC"}

2
esm/is.d.ts vendored
View File

@ -1,4 +1,4 @@
interface Is { export interface Is {
(object: any, path: string | number | (number | string)[], predicate: any): boolean; (object: any, path: string | number | (number | string)[], predicate: any): boolean;
(path: string | number | (number | string)[], predicate: any): (object: any) => boolean; (path: string | number | (number | string)[], predicate: any): (object: any) => boolean;
} }

View File

@ -1 +1 @@
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAsBA,UAAU,EAAE;IACR,CAAC,MAAM,KAAA,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,KAAA,GAAG,OAAO,CAAC;IAC1E,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,KAAA,GAAG,CAAC,MAAM,KAAA,KAAK,OAAO,CAAC;CACjF;;AAED,wBAA+B"} {"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,EAAE;IACjB,CAAC,MAAM,KAAA,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,KAAA,GAAG,OAAO,CAAC;IAC1E,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,KAAA,GAAG,CAAC,MAAM,KAAA,KAAK,OAAO,CAAC;CAC/E;;AAED,wBAA+B"}

View File

@ -1 +1 @@
{"version":3,"file":"is.js","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,SAAS,GAAG,CACR,MAAM,EACN,IAA2C,EAC3C,SAAS;IAET,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,KAAK,CAAC;QAChD,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;KACzB;IAED,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QACjC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;KAC5B;IAED,OAAO,SAAS,KAAK,MAAM,CAAC;AAChC,CAAC;AAOD,eAAe,IAAI,CAAC,GAAG,CAAO,CAAC"} {"version":3,"file":"is.js","sourceRoot":"","sources":["../src/is.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,SAAS,GAAG,CACV,MAAM,EACN,IAA2C,EAC3C,SAAS;IAET,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,KAAK,CAAC;QAChD,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;KACvB;IAED,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QACnC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;KAC1B;IAED,OAAO,SAAS,KAAK,MAAM,CAAC;AAC9B,CAAC;AAOD,eAAe,IAAI,CAAC,GAAG,CAAO,CAAC"}

Some files were not shown because too many files have changed in this diff Show More