@sparted/shared-library 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/linked-list/update-linked-list.js +2 -1
- package/linked-list/update-linked-list.js.map +1 -1
- package/object/merge-deep.js +2 -1
- package/object/merge-deep.js.map +1 -1
- package/object/strip-properties-from-object.js +1 -1
- package/object/strip-properties-from-object.js.map +1 -1
- package/package.json +13 -12
- package/predicates/is-null.js +1 -1
- package/predicates/is-null.js.map +1 -1
- package/types/object.d.ts +2 -2
|
@@ -9,8 +9,9 @@ const updateLinkedList = (item, config) => {
|
|
|
9
9
|
const { list, factory } = config;
|
|
10
10
|
linkedListUtils.assertPresence(item.id, list.items);
|
|
11
11
|
/**
|
|
12
|
-
* This method should not update any ids.
|
|
12
|
+
* This method should not update any ids, this is why they are removed from the item.
|
|
13
13
|
*/
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
15
|
const updatedProperties = _tslib.__rest(item, ["nextId", "previousId", "id"]);
|
|
15
16
|
const currentItem = list.items[item.id];
|
|
16
17
|
const newItems = Object.assign(Object.assign({}, list.items), { [item.id]: Object.assign({ nextId: currentItem.nextId, previousId: currentItem.previousId, id: currentItem.id }, updatedProperties) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-linked-list.js","sources":["../../src/linked-list/update-linked-list.ts"],"sourcesContent":["import { ManipulationConfig, LinkedListItem } from './type';\nimport { assertPresence } from './linked-list-utils';\n\nexport const updateLinkedList = <T extends LinkedListItem>(item: T, config: ManipulationConfig<T>) => {\n const { list, factory } = config;\n\n assertPresence(item.id, list.items);\n\n /**\n * This method should not update any ids.\n */\n const { nextId, previousId, id, ...updatedProperties } = item;\n const currentItem = list.items[item.id];\n\n const newItems = {\n ...list.items,\n [item.id]: {\n nextId: currentItem.nextId,\n previousId: currentItem.previousId,\n id: currentItem.id,\n ...updatedProperties,\n } as T,\n };\n\n return factory({\n headId: list.headId,\n items: newItems,\n });\n};\n"],"names":["assertPresence","__rest"],"mappings":";;;;;;;MAGa,gBAAgB,GAAG,CAA2B,IAAO,EAAE,MAA6B,KAAI;AACnG,IAAA,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAEjCA,8BAAc,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;AAEpC;;AAEG
|
|
1
|
+
{"version":3,"file":"update-linked-list.js","sources":["../../src/linked-list/update-linked-list.ts"],"sourcesContent":["import { ManipulationConfig, LinkedListItem } from './type';\nimport { assertPresence } from './linked-list-utils';\n\nexport const updateLinkedList = <T extends LinkedListItem>(item: T, config: ManipulationConfig<T>) => {\n const { list, factory } = config;\n\n assertPresence(item.id, list.items);\n\n /**\n * This method should not update any ids, this is why they are removed from the item.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { nextId, previousId, id, ...updatedProperties } = item;\n const currentItem = list.items[item.id];\n\n const newItems = {\n ...list.items,\n [item.id]: {\n nextId: currentItem.nextId,\n previousId: currentItem.previousId,\n id: currentItem.id,\n ...updatedProperties,\n } as T,\n };\n\n return factory({\n headId: list.headId,\n items: newItems,\n });\n};\n"],"names":["assertPresence","__rest"],"mappings":";;;;;;;MAGa,gBAAgB,GAAG,CAA2B,IAAO,EAAE,MAA6B,KAAI;AACnG,IAAA,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAEjCA,8BAAc,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;AAEpC;;AAEG;;AAEH,IAAA,MAAmC,iBAAiB,GAAKC,aAAA,CAAA,IAAI,EAAvD,CAAA,QAAA,EAAA,YAAA,EAAA,IAAA,CAAgD,EAAQ;IAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAExC,IAAA,MAAM,QAAQ,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACT,IAAI,CAAC,KAAK,CACb,EAAA,EAAA,CAAC,IAAI,CAAC,EAAE,GAAG,MACT,CAAA,MAAA,CAAA,EAAA,MAAM,EAAE,WAAW,CAAC,MAAM,EAC1B,UAAU,EAAE,WAAW,CAAC,UAAU,EAClC,EAAE,EAAE,WAAW,CAAC,EAAE,EAAA,EACf,iBAAiB,CAChB,GACP,CAAC;AAEF,IAAA,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,IAAI,CAAC,MAAM;AACnB,QAAA,KAAK,EAAE,QAAQ;AAChB,KAAA,CAAC,CAAC;AACL;;;;"}
|
package/object/merge-deep.js
CHANGED
|
@@ -4,12 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
// https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350
|
|
6
6
|
const isObject = (a) => typeof a === 'object' && a !== null;
|
|
7
|
-
const isValueType = (a) =>
|
|
7
|
+
const isValueType = (a) => !isObject(a) || Array.isArray(a);
|
|
8
8
|
const mergeDeep = (a, b) => {
|
|
9
9
|
if (isValueType(a) || isValueType(b)) {
|
|
10
10
|
return b;
|
|
11
11
|
}
|
|
12
12
|
return Object.keys(b).reduce((acc, key) => {
|
|
13
|
+
// @ts-ignore
|
|
13
14
|
if (!(key in a)) {
|
|
14
15
|
return acc;
|
|
15
16
|
}
|
package/object/merge-deep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-deep.js","sources":["../../src/object/merge-deep.ts"],"sourcesContent":["import type { DeepPartial, ValueType } from '../types';\n\n// https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350\nconst isObject = (a: any) => typeof a === 'object' && a !== null;\nconst isValueType = (a: any): a is ValueType =>
|
|
1
|
+
{"version":3,"file":"merge-deep.js","sources":["../../src/object/merge-deep.ts"],"sourcesContent":["import type { DeepPartial, ValueType } from '../types';\n\n// https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript/8511350#8511350\nconst isObject = (a: any) => typeof a === 'object' && a !== null;\nconst isValueType = (a: any): a is ValueType => !isObject(a) || Array.isArray(a);\n\nexport const mergeDeep = <T>(a: T, b: DeepPartial<T>): T => {\n if (isValueType(a) || isValueType(b)) {\n return b as T;\n }\n\n return (Object.keys(b) as (keyof T)[]).reduce((acc, key) => {\n // @ts-ignore\n if (!(key in a)) {\n return acc;\n }\n\n if (b[key] === a[key]) {\n return acc;\n }\n\n const merged = mergeDeep(a[key], b[key] as DeepPartial<T[keyof T]>);\n\n return { ...acc, [key]: merged };\n }, a);\n};\n"],"names":[],"mappings":";;;;AAEA;AACA,MAAM,QAAQ,GAAG,CAAC,CAAM,KAAK,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC;AACjE,MAAM,WAAW,GAAG,CAAC,CAAM,KAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;MAEpE,SAAS,GAAG,CAAI,CAAI,EAAE,CAAiB,KAAO;IACzD,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE;AACpC,QAAA,OAAO,CAAM,CAAC;AACf,KAAA;AAED,IAAA,OAAQ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAI;;AAEzD,QAAA,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE;AACf,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;QAED,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE;AACrB,YAAA,OAAO,GAAG,CAAC;AACZ,SAAA;AAED,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAA4B,CAAC,CAAC;AAEpE,QAAA,OAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAY,GAAG,CAAE,EAAA,EAAA,CAAC,GAAG,GAAG,MAAM,EAAG,CAAA,CAAA;KAClC,EAAE,CAAC,CAAC,CAAC;AACR;;;;"}
|
|
@@ -18,7 +18,7 @@ const stripPropertiesFromObject = (obj, properties) => {
|
|
|
18
18
|
: nestedProperties
|
|
19
19
|
.slice(0, nestedProperties.length - 1)
|
|
20
20
|
.reduce((acc, property) => acc[property], copy);
|
|
21
|
-
if (nestedObject
|
|
21
|
+
if (nestedObject) {
|
|
22
22
|
delete nestedObject[propertyToRemove];
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strip-properties-from-object.js","sources":["../../src/object/strip-properties-from-object.ts"],"sourcesContent":["import structuredClone from '@ungap/structured-clone';\n\nexport const stripPropertiesFromObject = <Output extends Record<any, any>, Input extends Record<any, any>>(\n obj: Input,\n properties: string[],\n): Output => {\n const copy = structuredClone(obj);\n\n properties.forEach((nestedPropertyStr) => {\n const nestedProperties = nestedPropertyStr.split('.');\n const propertyToRemove = nestedProperties[nestedProperties.length - 1];\n\n const nestedObject
|
|
1
|
+
{"version":3,"file":"strip-properties-from-object.js","sources":["../../src/object/strip-properties-from-object.ts"],"sourcesContent":["import structuredClone from '@ungap/structured-clone';\n\nexport const stripPropertiesFromObject = <Output extends Record<any, any>, Input extends Record<any, any>>(\n obj: Input,\n properties: string[],\n): Output => {\n const copy = structuredClone(obj);\n\n properties.forEach((nestedPropertyStr) => {\n const nestedProperties = nestedPropertyStr.split('.');\n const propertyToRemove = nestedProperties[nestedProperties.length - 1];\n\n const nestedObject =\n nestedProperties.length === 1\n ? copy\n : nestedProperties\n .slice(0, nestedProperties.length - 1)\n .reduce((acc, property) => acc[property], copy);\n\n if (nestedObject) {\n delete nestedObject[propertyToRemove];\n }\n });\n\n return copy;\n};\n"],"names":["structuredClone"],"mappings":";;;;;;;;;;MAEa,yBAAyB,GAAG,CACvC,GAAU,EACV,UAAoB,KACV;AACV,IAAA,MAAM,IAAI,GAAGA,mCAAe,CAAC,GAAG,CAAC,CAAC;AAElC,IAAA,UAAU,CAAC,OAAO,CAAC,CAAC,iBAAiB,KAAI;QACvC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAEvE,QAAA,MAAM,YAAY,GAChB,gBAAgB,CAAC,MAAM,KAAK,CAAC;AAC3B,cAAE,IAAI;AACN,cAAE,gBAAgB;iBACb,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;AACrC,iBAAA,MAAM,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAK,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;AAExD,QAAA,IAAI,YAAY,EAAE;AAChB,YAAA,OAAO,YAAY,CAAC,gBAAgB,CAAC,CAAC;AACvC,SAAA;AACH,KAAC,CAAC,CAAC;AAEH,IAAA,OAAO,IAAI,CAAC;AACd;;;;"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparted/shared-library",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"repository": "git@github.com:Sparted/shared-library.git",
|
|
5
|
-
"author":
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Sparted",
|
|
7
|
+
"email": "developer@sparted.com",
|
|
8
|
+
"url": "https://www.sparted.com"
|
|
9
|
+
},
|
|
6
10
|
"license": "MIT",
|
|
7
11
|
"sideEffets": false,
|
|
8
12
|
"main": "index.js",
|
|
@@ -19,24 +23,21 @@
|
|
|
19
23
|
"build-and-publish": "yarn test && yarn build && (cd ./dist && NPM_CONFIG_REGISTRY=undefined npm publish)"
|
|
20
24
|
},
|
|
21
25
|
"devDependencies": {
|
|
22
|
-
"@sparted/eslint-config": "^1.0.0",
|
|
23
26
|
"@types/glob": "^8.0.0",
|
|
24
27
|
"@types/jest": "^29.0.3",
|
|
25
28
|
"@types/ungap__structured-clone": "^0.3.0",
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
27
|
-
"@typescript-eslint/parser": "^
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
30
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
28
31
|
"eslint": "^7.32.0",
|
|
29
|
-
"eslint-config-
|
|
30
|
-
"eslint-
|
|
31
|
-
"eslint-plugin-
|
|
32
|
-
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
33
|
-
"eslint-plugin-react": "^7.28.0",
|
|
34
|
-
"eslint-plugin-react-hooks": "^4.3.0",
|
|
32
|
+
"eslint-config-prettier": "^8.8.0",
|
|
33
|
+
"eslint-plugin-import": "^2.27.5",
|
|
34
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
35
35
|
"glob": "^8.0.3",
|
|
36
|
-
"jest": "^29.
|
|
36
|
+
"jest": "^29.6.1",
|
|
37
37
|
"jest-environment-jsdom": "^29.0.3",
|
|
38
38
|
"jest-extended": "^3.1.0",
|
|
39
39
|
"jest-fetch-mock": "^3.0.3",
|
|
40
|
+
"prettier": "2",
|
|
40
41
|
"rollup": "^2.79.1",
|
|
41
42
|
"rollup-plugin-typescript2": "^0.34.0",
|
|
42
43
|
"ts-jest": "^29.0.2",
|
package/predicates/is-null.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-null.js","sources":["../../src/predicates/is-null.ts"],"sourcesContent":["export const isNull = (value: any): value is null =>
|
|
1
|
+
{"version":3,"file":"is-null.js","sources":["../../src/predicates/is-null.ts"],"sourcesContent":["export const isNull = (value: any): value is null => value === null;\n"],"names":[],"mappings":";;;;AAAO,MAAM,MAAM,GAAG,CAAC,KAAU,KAAoB,KAAK,KAAK;;;;"}
|
package/types/object.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export declare type Methods<T> = {
|
|
|
17
17
|
export declare type PartialMethods<T> = {
|
|
18
18
|
[K in MethodKeys<T>]?: T[K];
|
|
19
19
|
};
|
|
20
|
-
export declare type ClassType<T> = {
|
|
21
|
-
new (...args:
|
|
20
|
+
export declare type ClassType<T, Params extends Array<any> = Array<any>> = {
|
|
21
|
+
new (...args: Params): T;
|
|
22
22
|
};
|
|
23
23
|
export declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
24
24
|
export declare type DeepPartial<T> = T extends ValueType ? T : {
|