You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

juri

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

juri - npm Package Compare versions

Comparing version

to
1.0.3

48

juri.js

@@ -8,9 +8,10 @@ "use strict";

Use of other URL-safe characters
. Dot in strings
_ Spaces in strings
- Value: Start of negative number
In numbers, negative exponent
-- is false
-* is -Infinity
-+ is null

@@ -21,3 +22,5 @@

++ is true
+- is null
+* is +Infinity
+- is undefined
+! is NaN

@@ -39,3 +42,3 @@ ! (unused)

var encMap = {}, decMap = {}, dictReg;
if(Array.isArray(dictionary)) {

@@ -69,3 +72,3 @@ dictionary.splice(64);

}
function encodeInteger(t) {

@@ -96,3 +99,3 @@ var s = "";

var i, m, n, r = "", u = false;
for(i = 0; i < run.length; i++) {

@@ -162,3 +165,3 @@ m = run[i];

}
parts = parts.split(/[eE]/g);

@@ -176,3 +179,3 @@ if(parts[1]) { exp = parseInt(parts[1]); }

});
s += (encodeInteger(parseInt(sig)) || "0");

@@ -197,9 +200,9 @@

for(i = 0; i < value.length; i++) {
s.push(encode(typeof value[i] === "undefined" ? null : value[i]));
s.push(encode(value[i]));
}
} else {
k = Object.keys(value).sort();
if (!k.length && !qStr) { s.push(":"); }
for(j = 0; j < k.length; j++) {

@@ -223,3 +226,3 @@ i = k[j];

}
function terminate(expectedMode, preserve) {

@@ -230,3 +233,3 @@ mode = mode || expectedMode;

if(start === i) { return; }
if(mode === "key") {

@@ -283,3 +286,3 @@ key = decodeString(string.substring(start, i));

case "object":
if(value === null) { return "+-"; }
if(value === null) { return "-+"; }
return encodeCollection(value, qStr);

@@ -289,5 +292,10 @@ case "string":

case "number":
if (isNaN(value)) { return "+!"; }
if (value === +Infinity) { return "+*"; }
if (value === -Infinity) { return "-*"; }
return encodeNumber(value);
case "boolean":
return value ? "++" : "--";
case "undefined":
return "+-";
default:

@@ -304,8 +312,11 @@ return "";

case "-":
if(string[1] === "-") { return false; }
if(string[1] === "+") { return null; }
if (string[1] === "-") { return false; }
if (string[1] === "+") { return null; }
if (string[1] === "*") { return -Infinity; }
return decodeNumber(string);
case "+":
if(string[1] === "-") { return null; }
if(string[1] === "+") { return true; }
if (string[1] === "-") { return undefined; }
if (string[1] === "!") { return NaN; }
if (string[1] === "+") { return true; }
if (string[1] === "*") { return Infinity; }
return decodeNumber(string);

@@ -335,2 +346,1 @@ default:

};
{
"name": "juri",
"version": "1.0.2",
"version": "1.0.3",
"description": "Encode JSON into compact, readable URL-safe strings",
"main": "juri.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node test.js"
},

@@ -9,0 +9,0 @@ "repository": {

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

var assert = require("assert");
var dict = [ "red", "yellow", "orange", "blue", "green", "white",

@@ -18,3 +20,7 @@ "Asia", "North America", "South America",

leader: { name: "Narendra\nModi.", undef: undefined, title: "Prime Minister", term: 119 },
population: 1.19E9
population: 1.19E9,
nan: NaN,
infi: Infinity,
neginf: -Infinity,
nul: null
},

@@ -30,3 +36,3 @@ array: ["asdf", [3, undefined, 4]]

console.log("Decoded: ", decoded);
console.log(json == JSON.stringify(decoded)? "Correct": "Incorrect");
assert.deepEqual(data, decoded);
console.log(

@@ -39,4 +45,1 @@ "Compressed to " +

);