@symbo.ls/utils 3.14.12 → 3.14.13
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/CHANGELOG.md +6 -0
- package/dist/cjs/object.js +5 -5
- package/dist/esm/object.js +9 -9
- package/object.js +12 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/object.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const c=e[s];let f=!1;for(let l=0;l<s.length;l++)if(
|
|
1
|
+
"use strict";var _=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var o in t)_(e,o,{get:t[o],enumerable:!0})},B=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of R(t))!F.call(e,n)&&n!==o&&_(e,n,{get:()=>t[n],enumerable:!(r=M(t,n))||r.enumerable});return e};var G=e=>B(_({},"__esModule",{value:!0}),e);var he={};L(he,{clone:()=>q,createNestedObject:()=>ie,createObjectWithoutPrototype:()=>I,deepClone:()=>N,deepContains:()=>se,deepDestringifyFunctions:()=>x,deepMerge:()=>V,deepStringifyFunctions:()=>S,destringifyGlobalScope:()=>m,detectInfiniteLoop:()=>ae,excludeKeysFromObject:()=>ye,exec:()=>g,getInObjectByPath:()=>ue,hasFunction:()=>d,hasOwnProperty:()=>j,isCyclic:()=>pe,isEmpty:()=>D,isEmptyObject:()=>ee,isEqualDeep:()=>W,makeObjectWithoutPrototype:()=>te,map:()=>H,merge:()=>J,objectToString:()=>P,overwrite:()=>ne,overwriteDeep:()=>C,overwriteShallow:()=>re,removeFromObject:()=>ce,removeNestedKeyByPath:()=>fe,setInObjectByPath:()=>le,stringToObject:()=>b});module.exports=G(he);var O=require("./globals.js"),i=require("./types.js"),$=require("./array.js"),v=require("./string.js"),h=require("./node.js"),T=require("./keys.js");const k="production",w=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,g=(e,t,o,r)=>{if((0,i.isFunction)(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,r||t.context):void 0;if(e!=null&&t?.context?.plugins&&((0,i.isArray)(e)||(0,i.isObject)(e)&&!(0,h.isDOMNode)(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const c=s.resolveHandler(e,t);if(typeof c=="function")return g(c,t,o,r)}}return e},H=(e,t,o)=>{for(const r in t)e[r]=g(t[r],o)},J=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(w(n)||(r?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},V=(e,t,o=T.METHODS_EXL)=>E(e,t,o,null),E=(e,t,o,r)=>{if(e===t)return e;if(r){for(let s=0;s<r.length;s+=2)if(r[s]===e&&r[s+1]===t)return e}const n=o instanceof Set;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||w(s)||s==="constructor"||s==="prototype"||(n?o.has(s):o.includes(s)))continue;const c=e[s],f=t[s];if((0,i.isObjectLike)(c)&&(0,i.isObjectLike)(f)){const u=r||[];u.push(e,t),E(c,f,o,u),u.length-=2}else c===void 0&&(e[s]=f)}return e},q=(e,t=[])=>{const o=t instanceof Set,r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(w(n)||(o?t.has(n):t.includes(n))||(r[n]=e[n]));return r},N=(e,t={})=>{const{exclude:o=[],cleanUndefined:r=!1,cleanNull:n=!1,window:s,visited:c=new WeakMap,handleExtends:f=!1}=t,u=s||O.window||globalThis;if(!(0,i.isObjectLike)(e)||(0,h.isDOMNode)(e))return e;if(c.has(e))return c.get(e);const a=(0,i.isArray)(e)?[]:{};c.set(e,a);const A=o instanceof Set?o:o.length>3?new Set(o):null;for(const p in e){if(!Object.prototype.hasOwnProperty.call(e,p)||w(p)||p==="__proto__"||(A?A.has(p):o.includes(p)))continue;const y=e[p];if(!(r&&y===void 0)&&!(n&&y===null)){if((0,h.isDOMNode)(y)){a[p]=y;continue}if(f&&p==="extends"&&(0,i.isArray)(y)){a[p]=(0,$.unstackArrayOfObjects)(y,o);continue}if((0,i.isFunction)(y)){a[p]=y;continue}(0,i.isObjectLike)(y)?a[p]=N(y,{...t,visited:c}):a[p]=y}}return a},S=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const r=e[o];if((0,i.isFunction)(r))t[o]=r.toString();else if((0,i.isObject)(r))t[o]={},S(r,t[o]);else if((0,i.isArray)(r)){const n=t[o]=[];for(let s=0;s<r.length;s++){const c=r[s];(0,i.isObject)(c)?(n[s]={},S(c,n[s])):(0,i.isFunction)(c)?n[s]=c.toString():n[s]=c}}else t[o]=r}return t},z=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),P=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let o=!1;for(const s in e){o=!0;break}if(!o)return"{}";const r=" ".repeat(t);let n=`{
|
|
2
|
+
`;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const c=e[s];let f=!1;for(let l=0;l<s.length;l++)if(z.has(s[l])){f=!0;break}const u=f?`'${s}'`:s;if(n+=`${r} ${u}: `,(0,i.isArray)(c)){n+=`[
|
|
3
3
|
`;for(const l of c)(0,i.isObjectLike)(l)&&l!==null?n+=`${r} ${P(l,t+2)},
|
|
4
4
|
`:(0,i.isString)(l)?n+=`${r} '${l}',
|
|
5
5
|
`:n+=`${r} ${l},
|
|
6
6
|
`;n+=`${r} ]`}else(0,i.isObjectLike)(c)?n+=P(c,t+1):(0,i.isString)(c)?n+=(0,v.stringIncludesAny)(c,[`
|
|
7
7
|
`,"'"])?`\`${c}\``:`'${c}'`:n+=c;n+=`,
|
|
8
|
-
`}return n+=`${r}}`,n},K=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],U=/^["[{]/,d=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||!K.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||U.test(t)&&!n)},
|
|
8
|
+
`}return n+=`${r}}`,n},K=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],U=/^["[{]/,d=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||!K.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||U.test(t)&&!n)},Y=e=>(0,eval)(e),x=(e,t={},o={window:{eval:Y}})=>{for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const n=e[r];if((0,i.isString)(n))if(d(n))try{t[r]=o.window.eval(`(${n})`)}catch(s){typeof console<"u"&&console.warn&&console.warn('[smbls] deepDestringifyFunctions: eval failed on "'+r+'" \u2014 function will be left as a string and el.call("'+r+'") will silently no-op. Reason: '+(s&&s.message?s.message:String(s))+`.
|
|
9
9
|
First 200 chars of source: `+String(n).slice(0,200)),t[r]=n}else t[r]=n;else if((0,i.isArray)(n)){const s=t[r]=[];for(let c=0;c<n.length;c++){const f=n[c];if((0,i.isString)(f))if(d(f))try{s.push(o.window.eval(`(${f})`))}catch(u){typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed in array at index ${c} (prop "${r}"). Reason: ${u&&u.message?u.message:String(u)}.
|
|
10
|
-
First 200 chars: ${String(f).slice(0,200)}`),s.push(f)}else s.push(f);else(0,i.isObject)(f)?s.push(x(f)):s.push(f)}}else(0,i.isObject)(n)?t[r]=x(n,t[r]):t[r]=n}return t},Q=e=>!e||typeof e!="object"?e:e.__type===
|
|
10
|
+
First 200 chars: ${String(f).slice(0,200)}`),s.push(f)}else s.push(f);else(0,i.isObject)(f)?s.push(x(f)):s.push(f)}}else(0,i.isObject)(n)?t[r]=x(n,t[r]):t[r]=n}return t},Z="Set",Q="Map",X=e=>!e||typeof e!="object"?e:e.__type===Z&&Array.isArray(e.values)?new Set(e.values):e.__type===Q&&Array.isArray(e.entries)?new Map(e.entries):e,m=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const r of Object.keys(e)){const n=e[r];(0,i.isString)(n)&&d(n)?o.push([r,n]):t[r]=X(n)}for(const[r,n]of o)try{const s=Object.keys(t).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
|
|
11
11
|
`);t[r]=O.window.eval(`(function(__gs__) { ${s}
|
|
12
|
-
return (${n}); })`)(t)}catch{try{t[r]=O.window.eval(`(${n})`)}catch{t[r]=n}}return t},
|
|
12
|
+
return (${n}); })`)(t)}catch{try{t[r]=O.window.eval(`(${n})`)}catch{t[r]=n}}return t},b=(e,t={verbose:!0})=>{try{return e?O.window.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},j=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),D=e=>{for(const t in e)return!1;return!0},ee=e=>(0,i.isObject)(e)&&D(e),te=()=>Object.create(null),ne=(e,t,o={})=>{const r=o.exclude||[],n=o.preventUnderscore;for(const s in t)r.includes(s)||!n&&w(s)||s==="constructor"||s==="prototype"||t[s]!==void 0&&(e[s]=t[s]);return e},re=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)w(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n))||(e[n]=t[n]);return e},C=(e,t,o={},r=new WeakMap)=>{if(!(0,i.isObjectLike)(e)||!(0,i.isObjectLike)(t)||(0,h.isDOMNode)(e)||(0,h.isDOMNode)(t))return t;if(r.has(e))return r.get(e);r.set(e,e);const n=o.exclude,s=n?n instanceof Set?n:new Set(n):null,c=!o.preventForce;for(const f in t){if(!Object.prototype.hasOwnProperty.call(t,f)||s&&s.has(f)||c&&w(f)||f==="constructor"||f==="prototype")continue;const u=e[f],l=t[f];(0,h.isDOMNode)(l)?e[f]=l:(0,i.isObjectLike)(u)&&(0,i.isObjectLike)(l)?e[f]=C(u,l,o,r):l!==void 0&&(e[f]=l)}return e},W=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s=0;s<r.length;s++){const c=r[s];if(!Object.prototype.hasOwnProperty.call(t,c)||!W(e[c],t[c],o))return!1}return!0},oe=new Set(["node","__ref"]),se=(e,t,o=oe)=>{if(e===t)return!0;if(!(0,i.isObjectLike)(e)||!(0,i.isObjectLike)(t)||(0,h.isDOMNode)(e)||(0,h.isDOMNode)(t))return e===t;const r=o instanceof Set?o:new Set(o),n=new WeakSet;function s(c,f){if(n.has(f))return!0;n.add(f);for(const u in f){if(!Object.prototype.hasOwnProperty.call(f,u)||r.has(u))continue;if(!Object.prototype.hasOwnProperty.call(c,u))return!1;const l=f[u],a=c[u];if((0,h.isDOMNode)(l)||(0,h.isDOMNode)(a)){if(l!==a)return!1}else if((0,i.isObjectLike)(l)&&(0,i.isObjectLike)(a)){if(!s(a,l))return!1}else if(l!==a)return!1}return!0}return s(e,t)},ce=(e,t)=>{if(t==null)return e;if((0,i.is)(t)("string","number"))delete e[t];else if((0,i.isArray)(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},I=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=I(e[o]));return t},ie=(e,t)=>{if(e.length===0)return t;const o={};let r=o;for(let n=0;n<e.length;n++)n===e.length-1&&t?r[e[n]]=t:(r[e[n]]={},r=r[e[n]]);return o},fe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++){if(o[t[n]]===void 0)return;o=o[t[n]]}const r=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,r)&&delete o[r]},le=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++)(!r[t[n]]||typeof r[t[n]]!="object")&&(r[t[n]]={}),r=r[t[n]];return r[t[t.length-1]]=o,e},ue=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length;r++){if(o==null)return;o=o[t[r]]}return o},ae=e=>{let o=[],r=0;for(let n=0;n<e.length;n++)if(o.length<2)o.push(e[n]);else if(e[n]===o[n%2]?r++:(o=[e[n-1],e[n]],r=1),r>=20)return(k==="test"||k==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},pe=e=>{const t=new WeakSet;function o(r){if(r&&typeof r=="object"){if(t.has(r))return!0;t.add(r);for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&o(r[n]))return console.log(r,"cycle at "+n),!0}return!1}return o(e)},ye=(e,t)=>{const o=t instanceof Set?t:new Set(t),r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!o.has(n)&&(r[n]=e[n]);return r};
|
package/dist/esm/object.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{window as
|
|
2
|
-
`;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const c=e[s];let i=!1;for(let f=0;f<s.length;f++)if(
|
|
1
|
+
import{window as g}from"./globals.js";import{isFunction as S,isObjectLike as u,isObject as d,isArray as w,isString as _,is as N}from"./types.js";import{unstackArrayOfObjects as D}from"./array.js";import{stringIncludesAny as C}from"./string.js";import{isDOMNode as h}from"./node.js";import{METHODS_EXL as W}from"./keys.js";const A="production",O=e=>e.charCodeAt(0)===95&&e.charCodeAt(1)===95,k=(e,t,o,r)=>{if(S(e))return t?typeof e.call!="function"?e:e.call(t,t,o||t.state,r||t.context):void 0;if(e!=null&&t?.context?.plugins&&(w(e)||d(e)&&!h(e))){const n=t.context.plugins;for(const s of n)if(s.resolveHandler){const c=s.resolveHandler(e,t);if(typeof c=="function")return k(c,t,o,r)}}return e},b=(e,t,o)=>{for(const r in t)e[r]=k(t[r],o)},j=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(O(n)||(r?o.has(n):o.includes(n))||e[n]===void 0&&(e[n]=t[n]));return e},ee=(e,t,o=W)=>E(e,t,o,null),E=(e,t,o,r)=>{if(e===t)return e;if(r){for(let s=0;s<r.length;s+=2)if(r[s]===e&&r[s+1]===t)return e}const n=o instanceof Set;for(const s in t){if(!Object.prototype.hasOwnProperty.call(t,s)||O(s)||s==="constructor"||s==="prototype"||(n?o.has(s):o.includes(s)))continue;const c=e[s],i=t[s];if(u(c)&&u(i)){const l=r||[];l.push(e,t),E(c,i,o,l),l.length-=2}else c===void 0&&(e[s]=i)}return e},te=(e,t=[])=>{const o=t instanceof Set,r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(O(n)||(o?t.has(n):t.includes(n))||(r[n]=e[n]));return r},I=(e,t={})=>{const{exclude:o=[],cleanUndefined:r=!1,cleanNull:n=!1,window:s,visited:c=new WeakMap,handleExtends:i=!1}=t,l=s||g||globalThis;if(!u(e)||h(e))return e;if(c.has(e))return c.get(e);const a=w(e)?[]:{};c.set(e,a);const x=o instanceof Set?o:o.length>3?new Set(o):null;for(const p in e){if(!Object.prototype.hasOwnProperty.call(e,p)||O(p)||p==="__proto__"||(x?x.has(p):o.includes(p)))continue;const y=e[p];if(!(r&&y===void 0)&&!(n&&y===null)){if(h(y)){a[p]=y;continue}if(i&&p==="extends"&&w(y)){a[p]=D(y,o);continue}if(S(y)){a[p]=y;continue}u(y)?a[p]=I(y,{...t,visited:c}):a[p]=y}}return a},$=(e,t={})=>{(e.node||e.__ref||e.parent||e.__element||e.parse)&&((e.__element||e.parent?.__element).warn("Trying to clone element or state at",e),e=e.parse?.());for(const o in e){const r=e[o];if(S(r))t[o]=r.toString();else if(d(r))t[o]={},$(r,t[o]);else if(w(r)){const n=t[o]=[];for(let s=0;s<r.length;s++){const c=r[s];d(c)?(n[s]={},$(c,n[s])):S(c)?n[s]=c.toString():n[s]=c}}else t[o]=r}return t},M=new Set(["&","*","-",":","%","{","}",">","<","@",".","/","!"," "]),v=(e={},t=0)=>{if(e===null||typeof e!="object")return String(e);let o=!1;for(const s in e){o=!0;break}if(!o)return"{}";const r=" ".repeat(t);let n=`{
|
|
2
|
+
`;for(const s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;const c=e[s];let i=!1;for(let f=0;f<s.length;f++)if(M.has(s[f])){i=!0;break}const l=i?`'${s}'`:s;if(n+=`${r} ${l}: `,w(c)){n+=`[
|
|
3
3
|
`;for(const f of c)u(f)&&f!==null?n+=`${r} ${v(f,t+2)},
|
|
4
|
-
`:
|
|
4
|
+
`:_(f)?n+=`${r} '${f}',
|
|
5
5
|
`:n+=`${r} ${f},
|
|
6
|
-
`;n+=`${r} ]`}else u(c)?n+=v(c,t+1):
|
|
6
|
+
`;n+=`${r} ]`}else u(c)?n+=v(c,t+1):_(c)?n+=C(c,[`
|
|
7
7
|
`,"'"])?`\`${c}\``:`'${c}'`:n+=c;n+=`,
|
|
8
|
-
`}return n+=`${r}}`,n},
|
|
9
|
-
First 200 chars of source: `+String(n).slice(0,200)),t[r]=n}else t[r]=n;else if(w(n)){const s=t[r]=[];for(let c=0;c<n.length;c++){const i=n[c];if(
|
|
10
|
-
First 200 chars: ${String(i).slice(0,200)}`),s.push(i)}else s.push(i);else d(i)?s.push(
|
|
11
|
-
`);t[r]=
|
|
12
|
-
return (${n}); })`)(t)}catch{try{t[r]=
|
|
8
|
+
`}return n+=`${r}}`,n},R=[/^\(\s*\{[^}]*\}\s*\)\s*=>/,/^(\([^)]*\)|[^=]*)\s*=>/,/^function[\s(]/,/^async\s+/,/^\(\s*function/,/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/],F=/^["[{]/,P=e=>{if(!e)return!1;const t=e.trim().replace(/\n\s*/g," ").trim();if(t===""||t==="{}"||t==="[]"||!R.some(s=>s.test(t)))return!1;const r=t.charCodeAt(0),n=t.includes("=>");return!(r===123&&!n||r===91||F.test(t)&&!n)},L=e=>(0,eval)(e),T=(e,t={},o={window:{eval:L}})=>{for(const r in e){if(!Object.prototype.hasOwnProperty.call(e,r))continue;const n=e[r];if(_(n))if(P(n))try{t[r]=o.window.eval(`(${n})`)}catch(s){typeof console<"u"&&console.warn&&console.warn('[smbls] deepDestringifyFunctions: eval failed on "'+r+'" \u2014 function will be left as a string and el.call("'+r+'") will silently no-op. Reason: '+(s&&s.message?s.message:String(s))+`.
|
|
9
|
+
First 200 chars of source: `+String(n).slice(0,200)),t[r]=n}else t[r]=n;else if(w(n)){const s=t[r]=[];for(let c=0;c<n.length;c++){const i=n[c];if(_(i))if(P(i))try{s.push(o.window.eval(`(${i})`))}catch(l){typeof console<"u"&&console.warn&&console.warn(`[smbls] deepDestringifyFunctions: eval failed in array at index ${c} (prop "${r}"). Reason: ${l&&l.message?l.message:String(l)}.
|
|
10
|
+
First 200 chars: ${String(i).slice(0,200)}`),s.push(i)}else s.push(i);else d(i)?s.push(T(i)):s.push(i)}}else d(n)?t[r]=T(n,t[r]):t[r]=n}return t},B="Set",G="Map",H=e=>!e||typeof e!="object"?e:e.__type===B&&Array.isArray(e.values)?new Set(e.values):e.__type===G&&Array.isArray(e.entries)?new Map(e.entries):e,ne=e=>{if(!e||typeof e!="object")return e;const t={},o=[];for(const r of Object.keys(e)){const n=e[r];_(n)&&P(n)?o.push([r,n]):t[r]=H(n)}for(const[r,n]of o)try{const s=Object.keys(t).map(c=>`var ${c} = __gs__[${JSON.stringify(c)}];`).join(`
|
|
11
|
+
`);t[r]=g.eval(`(function(__gs__) { ${s}
|
|
12
|
+
return (${n}); })`)(t)}catch{try{t[r]=g.eval(`(${n})`)}catch{t[r]=n}}return t},re=(e,t={verbose:!0})=>{try{return e?g.eval("("+e+")"):{}}catch(o){t.verbose&&console.warn(o)}},oe=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t),J=e=>{for(const t in e)return!1;return!0},se=e=>d(e)&&J(e),ce=()=>Object.create(null),ie=(e,t,o={})=>{const r=o.exclude||[],n=o.preventUnderscore;for(const s in t)r.includes(s)||!n&&O(s)||s==="constructor"||s==="prototype"||t[s]!==void 0&&(e[s]=t[s]);return e},fe=(e,t,o=[])=>{const r=o instanceof Set;for(const n in t)O(n)||n==="constructor"||n==="prototype"||(r?o.has(n):o.includes(n))||(e[n]=t[n]);return e},V=(e,t,o={},r=new WeakMap)=>{if(!u(e)||!u(t)||h(e)||h(t))return t;if(r.has(e))return r.get(e);r.set(e,e);const n=o.exclude,s=n?n instanceof Set?n:new Set(n):null,c=!o.preventForce;for(const i in t){if(!Object.prototype.hasOwnProperty.call(t,i)||s&&s.has(i)||c&&O(i)||i==="constructor"||i==="prototype")continue;const l=e[i],f=t[i];h(f)?e[i]=f:u(l)&&u(f)?e[i]=V(l,f,o,r):f!==void 0&&(e[i]=f)}return e},q=(e,t,o=new Set)=>{if(typeof e!="object"||typeof t!="object"||e===null||t===null)return e===t;if(o.has(e)||o.has(t))return!0;o.add(e),o.add(t);const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s=0;s<r.length;s++){const c=r[s];if(!Object.prototype.hasOwnProperty.call(t,c)||!q(e[c],t[c],o))return!1}return!0},z=new Set(["node","__ref"]),le=(e,t,o=z)=>{if(e===t)return!0;if(!u(e)||!u(t)||h(e)||h(t))return e===t;const r=o instanceof Set?o:new Set(o),n=new WeakSet;function s(c,i){if(n.has(i))return!0;n.add(i);for(const l in i){if(!Object.prototype.hasOwnProperty.call(i,l)||r.has(l))continue;if(!Object.prototype.hasOwnProperty.call(c,l))return!1;const f=i[l],a=c[l];if(h(f)||h(a)){if(f!==a)return!1}else if(u(f)&&u(a)){if(!s(a,f))return!1}else if(f!==a)return!1}return!0}return s(e,t)},ue=(e,t)=>{if(t==null)return e;if(N(t)("string","number"))delete e[t];else if(w(t))for(let o=0;o<t.length;o++)delete e[t[o]];else throw new Error("Invalid input: props must be a string or an array of strings");return e},K=e=>{if(e===null||typeof e!="object")return e;const t=Object.create(null);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=K(e[o]));return t},ae=(e,t)=>{if(e.length===0)return t;const o={};let r=o;for(let n=0;n<e.length;n++)n===e.length-1&&t?r[e[n]]=t:(r[e[n]]={},r=r[e[n]]);return o},pe=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let n=0;n<t.length-1;n++){if(o[t[n]]===void 0)return;o=o[t[n]]}const r=t[t.length-1];o&&Object.prototype.hasOwnProperty.call(o,r)&&delete o[r]},ye=(e,t,o)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let r=e;for(let n=0;n<t.length-1;n++)(!r[t[n]]||typeof r[t[n]]!="object")&&(r[t[n]]={}),r=r[t[n]];return r[t[t.length-1]]=o,e},he=(e,t)=>{if(!Array.isArray(t))throw new Error("Path must be an array.");let o=e;for(let r=0;r<t.length;r++){if(o==null)return;o=o[t[r]]}return o},we=e=>{let o=[],r=0;for(let n=0;n<e.length;n++)if(o.length<2)o.push(e[n]);else if(e[n]===o[n%2]?r++:(o=[e[n-1],e[n]],r=1),r>=20)return(A==="test"||A==="development")&&console.warn("Warning: Potential infinite loop detected due to repeated sequence:",o),!0},Oe=e=>{const t=new WeakSet;function o(r){if(r&&typeof r=="object"){if(t.has(r))return!0;t.add(r);for(const n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&o(r[n]))return console.log(r,"cycle at "+n),!0}return!1}return o(e)},de=(e,t)=>{const o=t instanceof Set?t:new Set(t),r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&!o.has(n)&&(r[n]=e[n]);return r};export{te as clone,ae as createNestedObject,K as createObjectWithoutPrototype,I as deepClone,le as deepContains,T as deepDestringifyFunctions,ee as deepMerge,$ as deepStringifyFunctions,ne as destringifyGlobalScope,we as detectInfiniteLoop,de as excludeKeysFromObject,k as exec,he as getInObjectByPath,P as hasFunction,oe as hasOwnProperty,Oe as isCyclic,J as isEmpty,se as isEmptyObject,q as isEqualDeep,ce as makeObjectWithoutPrototype,b as map,j as merge,v as objectToString,ie as overwrite,V as overwriteDeep,fe as overwriteShallow,ue as removeFromObject,pe as removeNestedKeyByPath,ye as setInObjectByPath,re as stringToObject};
|
package/object.js
CHANGED
|
@@ -449,20 +449,22 @@ export const deepDestringifyFunctions = (
|
|
|
449
449
|
return destringified
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
+
// Tag values must stay in lockstep with plugins/frank/globalScopeBuilder.js
|
|
453
|
+
// (the serializer side). End-to-end contract covered by
|
|
454
|
+
// destringifyGlobalScope-set-map.test.js.
|
|
455
|
+
const TYPE_TAG_SET = 'Set'
|
|
456
|
+
const TYPE_TAG_MAP = 'Map'
|
|
457
|
+
|
|
452
458
|
/**
|
|
453
|
-
* Rehydrate Set / Map tagged forms
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
* the JSON round-trip (FT-FRANK-1).
|
|
458
|
-
*
|
|
459
|
-
* Pass-through for any other value. Cheap shape check by `__type` so
|
|
460
|
-
* normal user objects aren't perturbed.
|
|
459
|
+
* Rehydrate Set / Map tagged forms back into real Set / Map instances.
|
|
460
|
+
* Pass-through for any other value (including user objects that
|
|
461
|
+
* happen to carry an unrelated `__type` field — only `'Set'` / `'Map'`
|
|
462
|
+
* rehydrate).
|
|
461
463
|
*/
|
|
462
464
|
const _rehydrateTaggedValue = (val) => {
|
|
463
465
|
if (!val || typeof val !== 'object') return val
|
|
464
|
-
if (val.__type ===
|
|
465
|
-
if (val.__type ===
|
|
466
|
+
if (val.__type === TYPE_TAG_SET && Array.isArray(val.values)) return new Set(val.values)
|
|
467
|
+
if (val.__type === TYPE_TAG_MAP && Array.isArray(val.entries)) return new Map(val.entries)
|
|
466
468
|
return val
|
|
467
469
|
}
|
|
468
470
|
|