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

@blazingedge/update

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blazingedge/update - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

29

lib/index.js

@@ -130,6 +130,2 @@ 'use strict';

var replaceStarWithALL = function replaceStarWithALL(z) {
return z === '*' ? ALL : z;
};
var PropMatcher = function PropMatcher(key, value) {

@@ -164,5 +160,16 @@ return function (data) {

function parsePart(part) {
if (part[0] === '[') {
if (part.indexOf(']') !== part.length - 1) {
throw new Error('invalid or missing "]"');
}
part = part.slice(1, -1);
}
if (part === '*') return ALL;
return part;
}
function toPathParts(path) {
if (typeof path === 'string') {
return path.replace(/\]/g, '').split(/[.[]/).map(replaceStarWithALL);
return path.replace(/\[/g, '.[').split('.').map(parsePart);
}

@@ -183,4 +190,7 @@

var part = pathParts[pathIndex];
var partIsArray = isArray(part);
if (isFunc(part) || isArray(part)) {
if (partIsArray && part.length === 1) {
part = part[0];
} else if (partIsArray || isFunc(part)) {
if (!data) return data;

@@ -194,8 +204,9 @@

return map(data, f);
} else if (isFunc(part)) {
} else if (partIsArray) {
return mapProps(data, part, f);
} else {
// part is a function
return map(data, function (v) {
return part(v) ? f(v) : v;
});
} else {
return mapProps(data, part, f);
}

@@ -202,0 +213,0 @@ }

{
"name": "@blazingedge/update",
"version": "1.1.0",
"version": "1.1.1",
"description": "Utility for immutable deep updates of objects.",

@@ -10,3 +10,2 @@ "main": "lib",

"build": "npm run test && babel src -d lib",
"preversion": "npm run build",
"postversion": "git push && git push --tags"

@@ -28,3 +27,3 @@ },

"immutable",
"utiity",
"utility",
"reducers"

@@ -31,0 +30,0 @@ ],

@@ -114,4 +114,2 @@ const { isArray } = Array

const replaceStarWithALL = (z) => z === '*' ? ALL : z
const PropMatcher = (key, value) => data => !!data && data[key] === value

@@ -135,5 +133,16 @@

function parsePart (part) {
if (part[0] === '[') {
if (part.indexOf(']') !== part.length - 1) {
throw new Error('invalid or missing "]"')
}
part = part.slice(1, -1)
}
if (part === '*') return ALL
return part
}
function toPathParts (path) {
if (typeof path === 'string') {
return path.replace(/\]/g, '').split(/[.[]/).map(replaceStarWithALL)
return path.replace(/\[/g, '.[').split('.').map(parsePart)
}

@@ -153,5 +162,9 @@

const part = pathParts[pathIndex]
let part = pathParts[pathIndex]
const partIsArray = isArray(part)
if (isFunc(part) || isArray(part)) {
if (partIsArray && part.length === 1) {
part = part[0]
} else if (partIsArray || isFunc(part)) {
if (!data) return data

@@ -166,7 +179,7 @@

} else if (isFunc(part)) {
} else if (partIsArray) {
return mapProps(data, part, f)
} else { // part is a function
return map(data, (v) => part(v) ? f(v) : v)
} else {
return mapProps(data, part, f)
}

@@ -173,0 +186,0 @@ }

@@ -224,4 +224,14 @@ const test = require('tape')

result = update(data, ['list', [2]], REMOVE)
t.same(result, {
list: [
{ id: 1, count: 1, active: false, user: { name: 'Alex' } },
{ id: 2, count: 0, active: true, user: { name: 'Alex' } },
{ id: 4, count: 0, active: false, user: { name: 'Alex' } },
],
})
t.end()
})
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