@stacksjs/objects 0.75.422 → 0.75.431
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/dist/index.d.ts +11 -0
- package/dist/index.js +1 -1
- package/dist/transform.d.ts +6 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,17 @@ export declare function objectEntries<T extends object>(obj: T): boolean;
|
|
|
51
51
|
/**
|
|
52
52
|
* Deep merge :P
|
|
53
53
|
*
|
|
54
|
+
* A `"__proto__"` key in a source is skipped. `JSON.parse`, and the router's
|
|
55
|
+
* request input, keep one as an ordinary own key, and following it walked into
|
|
56
|
+
* `Object.prototype`: `deepMerge({}, JSON.parse('{"__proto__":{"isAdmin":true}}'))`
|
|
57
|
+
* made `isAdmin` true on every object in the process. Only the target's own
|
|
58
|
+
* properties are merged into, so an inherited one is never followed either.
|
|
59
|
+
*
|
|
60
|
+
* Only plain objects are merged key by key. A Date, Map, Set or class instance
|
|
61
|
+
* in a source is a value and is assigned; it used to be merged into a fresh
|
|
62
|
+
* `{}` and arrive empty. A string, array or number in the target gives way to
|
|
63
|
+
* a source's object; one that was truthy used to stay.
|
|
64
|
+
*
|
|
54
65
|
* @category Object
|
|
55
66
|
*/
|
|
56
67
|
export declare function deepMerge<T extends object = object, S extends object = T>(target: T, ...sources: S[]): DeepMerge<T, S>;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{notNullish as
|
|
2
|
+
import{notNullish as p}from"@stacksjs/utils";import{isObject as d}from"@stacksjs/validation";function k(e,t){let r=new Set(t);return Object.fromEntries(Object.entries(e).filter(([n])=>!r.has(n)))}function O(e,t){return Object.fromEntries(Object.entries(e).filter(([r,n])=>t(n,r)))}function l(e,t){return O(e,(r,n)=>!t(r,n))}function j(e,t){return Object.fromEntries(Object.entries(e).map(([r,n])=>[r,t(n,r)]))}function x(e,t){return Object.fromEntries(Object.entries(e).map(([r,n])=>[t(r,n),n]))}function K(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[String(r),t]))}function P(e){for(let t in e)if(Object.hasOwn(e,t))return!1;return!0}function g(e,t,r){let n=e;for(let s of t){if(n===null||n===void 0)return r;n=n[s]}return n===void 0?r:n}function y(e,t,r){if(t.length===0)return r;let[n,...s]=t,i=Array.isArray(e)?[...e]:{...e};if(s.length===0)return f(i,n,r),i;let o=Object.hasOwn(i,n)?i[n]:void 0,u=o===null||typeof o!=="object"?typeof s[0]==="number"?[]:{}:o;return f(i,n,y(u,s,r)),i}function f(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function h(e,t){return Object.fromEntries(Object.entries(e).map(([r,n])=>t(r,n)).filter(p))}function R(e,t){return t in e}function S(e){return Object.keys(e)}function E(e){return Object.entries(e)}function a(e,...t){if(!t.length)return e;let[r,...n]=t;if(r===void 0)return e;if(c(e)&&c(r)){let s=e,i=r;for(let o of Object.keys(i)){if(o==="__proto__")continue;if(b(i[o])){if(!Object.hasOwn(s,o)||!c(s[o]))s[o]={};a(s[o],i[o])}else s[o]=i[o]}}return a(e,...n)}function c(e){return d(e)&&!Array.isArray(e)}function b(e){if(typeof e!=="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null}function V(e,t,r=!1){return Object.fromEntries(t.filter((n)=>(n in e)&&(!r||e[n]!==void 0)).map((n)=>[n,e[n]]))}function N(e){return Object.keys(e).forEach((t)=>e[t]===void 0&&delete e[t]),e}function A(e,t){return e==null?!1:Object.prototype.hasOwnProperty.call(e,t)}export{N as clearUndefined,a as deepMerge,g as getPath,A as hasOwnProperty,K as invert,P as isEmptyObject,R as isKeyOf,x as mapKeys,j as mapValues,E as objectEntries,S as objectKeys,h as objectMap,V as objectPick,k as omit,l as omitBy,O as pickBy,y as setPath};
|
package/dist/transform.d.ts
CHANGED
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
* otherwise. Only an object's own enumerable string keys are visited -
|
|
12
12
|
* inherited and symbol keys are left alone, which matches `Object.entries` and
|
|
13
13
|
* is what stops a plain-object helper from wandering into a prototype.
|
|
14
|
+
*
|
|
15
|
+
* Results are built with `Object.fromEntries`, and `setPath` defines its key,
|
|
16
|
+
* because an assignment runs the `__proto__` setter. `JSON.parse` and the
|
|
17
|
+
* router's request input keep a `"__proto__"` key as an ordinary own key, so
|
|
18
|
+
* `omit(body, ['password'])` on `{"__proto__":{"isAdmin":true}}` used to come
|
|
19
|
+
* back with `isAdmin` true, inherited from a prototype the client chose.
|
|
14
20
|
*/
|
|
15
21
|
/**
|
|
16
22
|
* A copy without the given keys.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/objects",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.75.
|
|
4
|
+
"version": "0.75.431",
|
|
5
5
|
"description": "The Stacks objects.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"prepublishOnly": "bun run build"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@stacksjs/utils": "0.75.
|
|
60
|
-
"@stacksjs/validation": "0.75.
|
|
59
|
+
"@stacksjs/utils": "0.75.431",
|
|
60
|
+
"@stacksjs/validation": "0.75.431"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@stacksjs/collections": "0.75.
|
|
64
|
-
"@stacksjs/types": "0.75.
|
|
63
|
+
"@stacksjs/collections": "0.75.431",
|
|
64
|
+
"@stacksjs/types": "0.75.431",
|
|
65
65
|
"better-dx": "^0.2.24"
|
|
66
66
|
},
|
|
67
67
|
"sideEffects": false
|