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

jsonschema-key-compression

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonschema-key-compression - npm Package Compare versions

Comparing version 1.6.1 to 1.7.0

24

dist/es/compress.js

@@ -15,9 +15,11 @@ /**

// object
var ret_1 = {};
Object.keys(obj).forEach(function (key) {
var ret = {};
var keys = Object.keys(obj);
for (var index = 0; index < keys.length; index++) {
var key = keys[index];
var compressedKey = compressedAndFlaggedKey(table, key);
var value = compressObject(table, obj[key]);
ret_1[compressedKey] = value;
});
return ret_1;
ret[compressedKey] = value;
}
return ret;
}

@@ -50,7 +52,7 @@ }

* keys could be array-accessors like myArray[4]
* we have to split and readd the squared brackets value
* we have to split and read the squared brackets value
*/
var splitSquaredBrackets = key.split('[');
key = splitSquaredBrackets.shift();
var compressedKey = table.compressedToUncompressed.get(key);
var plainKey = splitSquaredBrackets.shift();
var compressedKey = table.compressedToUncompressed.get(plainKey);
if (!compressedKey) {

@@ -124,3 +126,3 @@ return key;

else if (typeof selector === 'object' && selector !== null) {
var ret_2 = {};
var ret_1 = {};
Object.keys(selector).forEach(function (key) {

@@ -136,5 +138,5 @@ var useKey;

}
ret_2[useKey] = compressQuerySelector(table, selector[key]);
ret_1[useKey] = compressQuerySelector(table, selector[key]);
});
return ret_2;
return ret_1;
}

@@ -141,0 +143,0 @@ else {

@@ -10,9 +10,11 @@ export function decompressObject(table, obj) {

// object
var ret_1 = {};
Object.keys(obj).forEach(function (key) {
var ret = {};
var keys = Object.keys(obj);
for (var index = 0; index < keys.length; index++) {
var key = keys[index];
var decompressed = decompressedKey(table, key);
var value = decompressObject(table, obj[key]);
ret_1[decompressed] = value;
});
return ret_1;
ret[decompressed] = value;
}
return ret;
}

@@ -41,4 +43,4 @@ }

var splitSquaredBrackets = key.split('[');
key = splitSquaredBrackets.shift();
var decompressed = table.uncompressedToCompressed.get(key);
var plainKey = splitSquaredBrackets.shift();
var decompressed = table.uncompressedToCompressed.get(plainKey);
if (!decompressed) {

@@ -45,0 +47,0 @@ return key;

@@ -6,3 +6,3 @@ /**

export declare function numberToLetter(nr: number): string;
export declare type SortComparator<T = any> = (a: T, y: T) => -1 | 1 | 0;
export type SortComparator<T = any> = (a: T, y: T) => -1 | 1 | 0;
export declare const alphabeticCompare: SortComparator;

@@ -9,0 +9,0 @@ /**

@@ -18,9 +18,11 @@ "use strict";

// object
var ret_1 = {};
Object.keys(obj).forEach(function (key) {
var ret = {};
var keys = Object.keys(obj);
for (var index = 0; index < keys.length; index++) {
var key = keys[index];
var compressedKey = compressedAndFlaggedKey(table, key);
var value = compressObject(table, obj[key]);
ret_1[compressedKey] = value;
});
return ret_1;
ret[compressedKey] = value;
}
return ret;
}

@@ -56,7 +58,7 @@ }

* keys could be array-accessors like myArray[4]
* we have to split and readd the squared brackets value
* we have to split and read the squared brackets value
*/
var splitSquaredBrackets = key.split('[');
key = splitSquaredBrackets.shift();
var compressedKey = table.compressedToUncompressed.get(key);
var plainKey = splitSquaredBrackets.shift();
var compressedKey = table.compressedToUncompressed.get(plainKey);
if (!compressedKey) {

@@ -132,3 +134,3 @@ return key;

else if (typeof selector === 'object' && selector !== null) {
var ret_2 = {};
var ret_1 = {};
Object.keys(selector).forEach(function (key) {

@@ -144,5 +146,5 @@ var useKey;

}
ret_2[useKey] = compressQuerySelector(table, selector[key]);
ret_1[useKey] = compressQuerySelector(table, selector[key]);
});
return ret_2;
return ret_1;
}

@@ -149,0 +151,0 @@ else {

@@ -13,9 +13,11 @@ "use strict";

// object
var ret_1 = {};
Object.keys(obj).forEach(function (key) {
var ret = {};
var keys = Object.keys(obj);
for (var index = 0; index < keys.length; index++) {
var key = keys[index];
var decompressed = decompressedKey(table, key);
var value = decompressObject(table, obj[key]);
ret_1[decompressed] = value;
});
return ret_1;
ret[decompressed] = value;
}
return ret;
}

@@ -46,4 +48,4 @@ }

var splitSquaredBrackets = key.split('[');
key = splitSquaredBrackets.shift();
var decompressed = table.uncompressedToCompressed.get(key);
var plainKey = splitSquaredBrackets.shift();
var decompressed = table.uncompressedToCompressed.get(plainKey);
if (!decompressed) {

@@ -50,0 +52,0 @@ return key;

@@ -6,3 +6,3 @@ /**

export declare function numberToLetter(nr: number): string;
export declare type SortComparator<T = any> = (a: T, y: T) => -1 | 1 | 0;
export type SortComparator<T = any> = (a: T, y: T) => -1 | 1 | 0;
export declare const alphabeticCompare: SortComparator;

@@ -9,0 +9,0 @@ /**

{
"name": "jsonschema-key-compression",
"version": "1.6.1",
"version": "1.7.0",
"description": "Compress json-data based on its json-schema",

@@ -32,4 +32,4 @@ "author": "pubkey",

"transpile:es": "tsc -p ./ --target ES5 --module ES6 --outDir ./dist/es && copyfiles -u 1 \"src/**/*.d.ts\" dist/es && echo '# transpile es6 (modules) sucess!'",
"build": "rimraf -r ./dist && npm run transpile && npm run transpile:es",
"test": "mocha -r ts-node/register test/unit/index.test.ts",
"build": "rimraf -fr ./dist && npm run transpile && npm run transpile:es",
"test": "mocha -r ts-node/register test/unit/index.test.ts --bail",
"test:performance": "mocha -r ts-node/register --bail --exit ./test/performance.test.ts",

@@ -41,16 +41,16 @@ "test:efficiency": "mocha -r ts-node/register --bail --exit ./test/efficiency.test.ts",

"@types/faker": "5.5.9",
"@types/mocha": "9.0.0",
"@types/node": "16.11.6",
"@types/node-gzip": "1.1.0",
"assert": "2.0.0",
"async-test-util": "2.0.0",
"@types/mocha": "10.0.6",
"@types/node": "20.11.16",
"@types/node-gzip": "1.1.3",
"assert": "2.1.0",
"async-test-util": "2.4.0",
"copyfiles": "2.4.1",
"faker": "5.5.3",
"mocha": "9.1.3",
"mocha": "10.2.0",
"node-gzip": "1.1.2",
"rimraf": "3.0.2",
"ts-node": "10.4.0",
"rimraf": "5.0.5",
"ts-node": "10.9.2",
"tslint": "6.1.3",
"typescript": "4.4.4"
"typescript": "5.3.3"
}
}

@@ -23,13 +23,15 @@ import type {

const ret: PlainJsonObject = {};
Object.keys(obj).forEach(key => {
const keys = Object.keys(obj);
for (let index = 0; index < keys.length; index++) {
const key = keys[index];
const compressedKey = compressedAndFlaggedKey(
table,
key
key as any
);
const value = compressObject(
table,
obj[key]
obj[key as any]
);
ret[compressedKey] = value;
});
}
return ret;

@@ -81,11 +83,9 @@ }

);
/**
* keys could be array-accessors like myArray[4]
* we have to split and readd the squared brackets value
* we have to split and read the squared brackets value
*/
const splitSquaredBrackets = key.split('[');
key = splitSquaredBrackets.shift() as string;
const compressedKey = table.compressedToUncompressed.get(key);
const plainKey = splitSquaredBrackets.shift() as string;
const compressedKey = table.compressedToUncompressed.get(plainKey);
if (!compressedKey) {

@@ -92,0 +92,0 @@ return key;

@@ -17,13 +17,15 @@ import type {

const ret: PlainJsonObject = {};
Object.keys(obj).forEach(key => {
const keys = Object.keys(obj);
for (let index = 0; index < keys.length; index++) {
const key = keys[index];
const decompressed = decompressedKey(
table,
key
key as any
);
const value = decompressObject(
table,
obj[key]
obj[key as any]
);
ret[decompressed] = value;
});
}
return ret;

@@ -65,5 +67,5 @@ }

const splitSquaredBrackets = key.split('[');
key = splitSquaredBrackets.shift() as string;
const plainKey = splitSquaredBrackets.shift() as string;
const decompressed = table.uncompressedToCompressed.get(key);
const decompressed = table.uncompressedToCompressed.get(plainKey);
if (!decompressed) {

@@ -70,0 +72,0 @@ return key;

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

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc