Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/mutator

Package Overview
Dependencies
Maintainers
7
Versions
1361
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/mutator - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

16

lib/jsonpath/arrayToJSONMatchPath.js

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

});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.default = arrayToJSONMatchPath;

@@ -14,4 +17,6 @@

function stringifySegment(segment, hasLeading) {
var isNumber = typeof segment === 'number';
var type = typeof segment === 'undefined' ? 'undefined' : _typeof(segment);
var isNumber = type === 'number';
if (isNumber) {

@@ -21,2 +26,11 @@ return '[' + segment + ']';

var isObject = type === 'object' && segment != null;
if (isObject) {
return Object.keys(segment).map(function (key) {
var val = segment[key];
return '[' + key + '==\'' + val + '\']';
}).join('');
}
if (IS_DOTTABLE.test(segment)) {

@@ -23,0 +37,0 @@ return hasLeading ? segment : '.' + segment;

2

package.json
{
"name": "@sanity/mutator",
"version": "0.1.1",
"version": "0.1.2",
"description": "A set of models to make it easier to utilize the powerful real time collaborative features of Sanity",

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

@@ -7,4 +7,6 @@ // @flow

function stringifySegment(segment, hasLeading) {
const isNumber = typeof segment === 'number'
const type = typeof segment
const isNumber = type === 'number'
if (isNumber) {

@@ -14,2 +16,11 @@ return `[${segment}]`

const isObject = type === 'object' && segment != null
if (isObject) {
return Object.keys(segment).map(key => {
const val = segment[key]
return `[${key}=='${val}']`
}).join('')
}
if (IS_DOTTABLE.test(segment)) {

@@ -22,3 +33,3 @@ return hasLeading ? segment : `.${segment}`

export default function arrayToJSONMatchPath(pathArray : Array<string|number>) : string {
export default function arrayToJSONMatchPath(pathArray : Array<string|number|object>) : string {
return pathArray.reduce((acc, segment, index) => {

@@ -25,0 +36,0 @@ return acc + stringifySegment(segment, index === 0)

@@ -12,3 +12,8 @@ // @flow

[[1, 'foo', 'bar', 4], '[1].foo.bar[4]'],
[[1, '-foo', 'bar', 4], "[1]['-foo'].bar[4]"]
[[1, '-foo', 'bar', 4], "[1]['-foo'].bar[4]"],
[[1, {foo: 'bar', bar: 'baz'}, 4], "[1][foo=='bar'][bar=='baz'][4]"]
// future maybe:
// [[1, [{foo: 'bar'}, {bar: 'baz'}], 4], "[1][foo=='bar'||bar=='baz'][4]"]
// [[1, {foo: 'bar', bar: 'baz'}, 4], "[1][foo=='bar'&&bar=='baz'][4]"]
]

@@ -15,0 +20,0 @@

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