Socket
Socket
Sign inDemoInstall

wild-wild-parser

Package Overview
Dependencies
3
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.3.0

13

build/src/normalize.js
import{parsePath,parseQuery}from"./parse/main.js";
import{normalizeQueryArrays}from"./validate/arrays.js";
import{normalizeArrayPath}from"./validate/path.js";
import{validatePath}from"./validate/path.js";
import{isQueryString}from"./validate/string.js";

@@ -82,6 +82,9 @@

export const normalizePath=function(query){
return isQueryString(query)?
parsePath(query):
normalizeArrayPath(query,query);
export const normalizePath=function(path){
if(isQueryString(path)){
return parsePath(path);
}
validatePath(path,path);
return path;
};

@@ -88,0 +91,0 @@

@@ -6,3 +6,3 @@ import moize from"moize";

import{normalizeQueryArrays}from"./validate/arrays.js";
import{normalizeArrayPath}from"./validate/path.js";
import{validatePath}from"./validate/path.js";

@@ -19,4 +19,4 @@

const mSerializePath=function(path){
const pathA=normalizeArrayPath(path,path);
return serializeQueryArray(pathA);
validatePath(path,path);
return serializeQueryArray(path);
};

@@ -23,0 +23,0 @@

@@ -37,11 +37,8 @@ import moize from"moize";

const mGetPathObjectTokenType=function(token){
return PATH_TOKEN_TYPES.find((tokenType)=>tokenType.testObject(token));
export const isPathToken=function(token){
return(
PROP_TOKEN.testObject(token)||
INDEX_TOKEN.testObject(token)&&token>=0&&!Object.is(token,-0));
};
export const getPathObjectTokenType=moize(mGetPathObjectTokenType,{
maxSize:1e3});
const PATH_TOKEN_TYPES=[PROP_TOKEN,INDEX_TOKEN];
//# sourceMappingURL=main.js.map

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

import{getPathObjectTokenType}from"../tokens/main.js";
import{isPathToken}from"../tokens/main.js";

@@ -17,7 +17,8 @@ import{throwQueryError,throwTokenError}from"./throw.js";

const[path]=queryArrays;
return normalizeArrayPath(path,query);
validatePathTokens(path,query);
return path;
};
export const normalizeArrayPath=function(path,query){
export const validatePath=function(path,query){
if(!Array.isArray(path)){

@@ -31,28 +32,20 @@ throwQueryError(query,"It must be an array.");

validatePathTokens(path,query);
};
const validatePathTokens=function(path,query){
path.forEach((prop)=>{
validateProp(prop,query);
validatePathToken(prop,query);
});
return path;
};
const validateProp=function(prop,query){
const tokenType=getPathObjectTokenType(prop);
if(tokenType===undefined){
const validatePathToken=function(prop,query){
if(!isPathToken(prop)){
throwTokenError(
query,
prop,
"It must be a property name or an array index.");
"It must be a property name or a positive array index.");
}
if(isNegativeIndex(tokenType,prop)){
throwTokenError(query,prop,"It must not be a negative index.");
}
};
const isNegativeIndex=function(tokenType,prop){
return tokenType.name==="index"&&(Object.is(prop,-0)||prop<0);
};
//# sourceMappingURL=path.js.map
{
"name": "wild-wild-parser",
"version": "2.2.0",
"version": "2.3.0",
"type": "module",

@@ -5,0 +5,0 @@ "exports": "./build/src/main.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc