New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

object-property-assigner

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-property-assigner - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

build/index.cjs.js

@@ -1,1 +0,1 @@

"use strict";const r=(r,e,t,n,o)=>{if(!n)throw new Error(o??`Invalid property path: ${e}\nCouldn't access "${t}" in ${JSON.stringify(r)}`)},e=r=>"object"==typeof r&&null!==r&&!Array.isArray(r),t=r=>Array.isArray(r),n=(r,e)=>r.filter(((r,t)=>t!==e)),o=(l,f,u,s)=>{const c=e(l)?{...l}:null,y=t(l)?[...l]:null;if(0===f.length)return l;if(!c&&!y)throw new Error("Can't assign property -- invalid input object");const{createNew:p,remove:m,noError:h,fullData:g,fullPath:d}=s,b=f[0];if(y&&"string"==typeof b)return y.map((r=>o(r,f,u,s)));if(1===f.length)return c&&"string"==typeof b?(a(c,b,u,s),c):y&&"number"==typeof b?(i(y,b,u,s),y):(r(g,d,b,h),l);const v=c||y||[];if(m&&2===f.length&&"number"==typeof f[1]){const e=v[b],o=f[1];return t(e)?v[b]=n(e,o):r(g,d,b,h,"Trying to remove an indexed item from an object that is not an array"),v}const w=f.slice(1);if(b in l){if(A=v[b],!t(A)&&!e(A)){if(!p)return r(g,d,b,h),v;v[b]={}}return v[b]=o(v[b],w,u,s),v}var A;if(p){const r="number"==typeof w[0]?[]:{};if(c)return v[b]=r,v[b]=o(v[b],w,u,s),v;if(y&&Array.isArray(v)){v.push(r);const e=v.length-1;return v[e]=o(v[e],w,u,s),v}}return r(g,d,b,h),v},a=(e,t,n,o)=>{const{remove:a,createNew:i,noError:l,fullData:f,fullPath:u}=o,s=t in e;a?s?delete e[t]:r(f,u,t,l):i||s?e[t]=n:r(f,u,t,l)},i=(e,t,n,o)=>{const{noError:a,fullData:i,fullPath:l,createNew:f}=o;t in e?e[t]=n:f?e.push(n):r(i,l,t,a)};module.exports=(r,e,a,i={})=>{const{remove:l=!1,createNew:f=!0,noError:u=!1}=i;var s;const c={remove:l,createNew:f,noError:u,fullData:r,fullPath:"string"==typeof(s=e)?s:"number"==typeof s?String(s):s.reduce(((r,e)=>"number"==typeof e?`${r}[${e}]`:""===r?e:`${r}.${e}`),"")},y=(r=>Array.isArray(r)?r:r.split(/(\.|\[\d+\])/).filter((r=>"."!==r&&""!==r)).map((r=>{const e=/\[(\d+)\]/.exec(r);return e?Number(e[1]):r})).flat())(e).filter((r=>""!==r));return t(r)&&l&&1===y.length?n(r,y[0]):o(r,y,a,c)};
"use strict";const r=(r,e,t,n,o)=>{if(!n)throw new Error(null!=o?o:`Invalid property path: ${e}\nCouldn't access "${t}" in ${JSON.stringify(r)}`)},e=r=>"object"==typeof r&&null!==r&&!Array.isArray(r),t=r=>Array.isArray(r),n=(r,e)=>r.filter(((r,t)=>t!==e)),o=(l,u,f,s)=>{const c=e(l)?Object.assign({},l):null,y=t(l)?[...l]:null;if(0===u.length)return l;if(!c&&!y)throw new Error("Can't assign property -- invalid input object");const{createNew:p,remove:m,noError:h,fullData:g,fullPath:b}=s,d=u[0];if(y&&"string"==typeof d)return y.map((r=>o(r,u,f,s)));if(1===u.length)return c&&"string"==typeof d?(a(c,d,f,s),c):y&&"number"==typeof d?(i(y,d,f,s),y):(r(g,b,d,h),l);const v=c||y||[];if(m&&2===u.length&&"number"==typeof u[1]){const e=v[d],o=u[1];return t(e)?v[d]=n(e,o):r(g,b,d,h,"Trying to remove an indexed item from an object that is not an array"),v}const w=u.slice(1);if(d in l){if(A=v[d],!t(A)&&!e(A)){if(!p)return r(g,b,d,h),v;v[d]={}}return v[d]=o(v[d],w,f,s),v}var A;if(p){const r="number"==typeof w[0]?[]:{};if(c)return v[d]=r,v[d]=o(v[d],w,f,s),v;if(y&&Array.isArray(v)){v.push(r);const e=v.length-1;return v[e]=o(v[e],w,f,s),v}}return r(g,b,d,h),v},a=(e,t,n,o)=>{const{remove:a,createNew:i,noError:l,fullData:u,fullPath:f}=o,s=t in e;a?s?delete e[t]:r(u,f,t,l):i||s?e[t]=n:r(u,f,t,l)},i=(e,t,n,o)=>{const{noError:a,fullData:i,fullPath:l,createNew:u}=o;t in e?e[t]=n:u?e.push(n):r(i,l,t,a)};module.exports=(r,e,a,i={})=>{const{remove:l=!1,createNew:u=!0,noError:f=!1}=i;var s;const c={remove:l,createNew:u,noError:f,fullData:r,fullPath:"string"==typeof(s=e)?s:"number"==typeof s?String(s):s.reduce(((r,e)=>"number"==typeof e?`${r}[${e}]`:""===r?e:`${r}.${e}`),"")},y=(r=>Array.isArray(r)?r:r.split(/(\.|\[\d+\])/).filter((r=>"."!==r&&""!==r)).map((r=>{const e=/\[(\d+)\]/.exec(r);return e?Number(e[1]):r})).flat())(e).filter((r=>""!==r));return t(r)&&l&&1===y.length?n(r,y[0]):o(r,y,a,c)};

@@ -1,1 +0,1 @@

const r=(r,e,t,n,o)=>{if(!n)throw new Error(o??`Invalid property path: ${e}\nCouldn't access "${t}" in ${JSON.stringify(r)}`)},e=r=>"object"==typeof r&&null!==r&&!Array.isArray(r),t=r=>Array.isArray(r),n=(r,e)=>r.filter(((r,t)=>t!==e)),o=(r,e,o,i={})=>{const{remove:l=!1,createNew:f=!0,noError:u=!1}=i;var s;const c={remove:l,createNew:f,noError:u,fullData:r,fullPath:"string"==typeof(s=e)?s:"number"==typeof s?String(s):s.reduce(((r,e)=>"number"==typeof e?`${r}[${e}]`:""===r?e:`${r}.${e}`),"")},y=(r=>Array.isArray(r)?r:r.split(/(\.|\[\d+\])/).filter((r=>"."!==r&&""!==r)).map((r=>{const e=/\[(\d+)\]/.exec(r);return e?Number(e[1]):r})).flat())(e).filter((r=>""!==r));return t(r)&&l&&1===y.length?n(r,y[0]):a(r,y,o,c)},a=(o,f,u,s)=>{const c=e(o)?{...o}:null,y=t(o)?[...o]:null;if(0===f.length)return o;if(!c&&!y)throw new Error("Can't assign property -- invalid input object");const{createNew:p,remove:h,noError:m,fullData:g,fullPath:d}=s,b=f[0];if(y&&"string"==typeof b)return y.map((r=>a(r,f,u,s)));if(1===f.length)return c&&"string"==typeof b?(i(c,b,u,s),c):y&&"number"==typeof b?(l(y,b,u,s),y):(r(g,d,b,m),o);const v=c||y||[];if(h&&2===f.length&&"number"==typeof f[1]){const e=v[b],o=f[1];return t(e)?v[b]=n(e,o):r(g,d,b,m,"Trying to remove an indexed item from an object that is not an array"),v}const w=f.slice(1);if(b in o){if(A=v[b],!t(A)&&!e(A)){if(!p)return r(g,d,b,m),v;v[b]={}}return v[b]=a(v[b],w,u,s),v}var A;if(p){const r="number"==typeof w[0]?[]:{};if(c)return v[b]=r,v[b]=a(v[b],w,u,s),v;if(y&&Array.isArray(v)){v.push(r);const e=v.length-1;return v[e]=a(v[e],w,u,s),v}}return r(g,d,b,m),v},i=(e,t,n,o)=>{const{remove:a,createNew:i,noError:l,fullData:f,fullPath:u}=o,s=t in e;a?s?delete e[t]:r(f,u,t,l):i||s?e[t]=n:r(f,u,t,l)},l=(e,t,n,o)=>{const{noError:a,fullData:i,fullPath:l,createNew:f}=o;t in e?e[t]=n:f?e.push(n):r(i,l,t,a)};export{o as default};
const r=(r,e,t,n,o)=>{if(!n)throw new Error(null!=o?o:`Invalid property path: ${e}\nCouldn't access "${t}" in ${JSON.stringify(r)}`)},e=r=>"object"==typeof r&&null!==r&&!Array.isArray(r),t=r=>Array.isArray(r),n=(r,e)=>r.filter(((r,t)=>t!==e)),o=(r,e,o,i={})=>{const{remove:l=!1,createNew:f=!0,noError:u=!1}=i;var s;const c={remove:l,createNew:f,noError:u,fullData:r,fullPath:"string"==typeof(s=e)?s:"number"==typeof s?String(s):s.reduce(((r,e)=>"number"==typeof e?`${r}[${e}]`:""===r?e:`${r}.${e}`),"")},y=(r=>Array.isArray(r)?r:r.split(/(\.|\[\d+\])/).filter((r=>"."!==r&&""!==r)).map((r=>{const e=/\[(\d+)\]/.exec(r);return e?Number(e[1]):r})).flat())(e).filter((r=>""!==r));return t(r)&&l&&1===y.length?n(r,y[0]):a(r,y,o,c)},a=(o,f,u,s)=>{const c=e(o)?Object.assign({},o):null,y=t(o)?[...o]:null;if(0===f.length)return o;if(!c&&!y)throw new Error("Can't assign property -- invalid input object");const{createNew:p,remove:h,noError:m,fullData:g,fullPath:b}=s,d=f[0];if(y&&"string"==typeof d)return y.map((r=>a(r,f,u,s)));if(1===f.length)return c&&"string"==typeof d?(i(c,d,u,s),c):y&&"number"==typeof d?(l(y,d,u,s),y):(r(g,b,d,m),o);const v=c||y||[];if(h&&2===f.length&&"number"==typeof f[1]){const e=v[d],o=f[1];return t(e)?v[d]=n(e,o):r(g,b,d,m,"Trying to remove an indexed item from an object that is not an array"),v}const w=f.slice(1);if(d in o){if(A=v[d],!t(A)&&!e(A)){if(!p)return r(g,b,d,m),v;v[d]={}}return v[d]=a(v[d],w,u,s),v}var A;if(p){const r="number"==typeof w[0]?[]:{};if(c)return v[d]=r,v[d]=a(v[d],w,u,s),v;if(y&&Array.isArray(v)){v.push(r);const e=v.length-1;return v[e]=a(v[e],w,u,s),v}}return r(g,b,d,m),v},i=(e,t,n,o)=>{const{remove:a,createNew:i,noError:l,fullData:f,fullPath:u}=o,s=t in e;a?s?delete e[t]:r(f,u,t,l):i||s?e[t]=n:r(f,u,t,l)},l=(e,t,n,o)=>{const{noError:a,fullData:i,fullPath:l,createNew:f}=o;t in e?e[t]=n:f?e.push(n):r(i,l,t,a)};export{o as default};
{
"name": "object-property-assigner",
"version": "1.2.0",
"version": "1.2.1",
"description": "A lightweight (no dependencies) tool to assign deeply nested properties in JS Objects (incl. Arrays)",

@@ -5,0 +5,0 @@ "main": "build/index.cjs.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc