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

noon

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

noon - npm Package Compare versions

Comparing version 0.4.5 to 0.5.1

32

js/inspect.js

@@ -12,3 +12,3 @@

inspect = function(l) {
var depth, key, p, value;
var depth, key, lit, p, value;
p = 0;

@@ -20,4 +20,10 @@ while (l[p] === ' ') {

key = '';
lit = false;
if (l[p] === '|') {
lit = true;
key += '|';
p += 1;
}
while (l[p] != null) {
if (l[p] === ' ' && l[p + 1] === ' ') {
if (l[p] === ' ' && l[p + 1] === ' ' && !lit) {
break;

@@ -27,3 +33,11 @@ }

p += 1;
if (lit && l[p - 1] === '|') {
break;
}
}
if (lit) {
lit = false;
} else {
key = key.trimRight();
}
while (l[p] === ' ') {

@@ -33,11 +47,17 @@ p += 1;

value = '';
if (l[p] === '|') {
lit = true;
value += '|';
p += 1;
}
while (l[p] != null) {
value += l[p];
p += 1;
if (lit && l[p - 1] === '|' && l.trimRight().length === p) {
break;
}
}
if (l[p - 1] === ' ') {
if (value) {
if (l[p - 1] === ' ' && !lit) {
if (value != null) {
value = value.trimRight();
} else {
key = key.trimRight();
}

@@ -44,0 +64,0 @@ }

26

js/parse.js

@@ -26,3 +26,3 @@

parse = function(s) {
var addLine, d, dd, dk, dv, e, i, indent, insert, j, k, len, len1, line, lines, m, makeObject, ref, ref1, ref2, stack, ud, v, value, values;
var addLine, d, dd, dk, dv, e, i, indent, insert, j, k, key, len, len1, line, lines, m, makeObject, ref, ref1, ref2, stack, ud, v, value, values;
lines = s.split('\n');

@@ -56,2 +56,11 @@ stack = [

};
key = function(k) {
if (k[0] === '|') {
if (k[k.length - 1] === '|') {
return k.substr(1, k.length - 2);
}
return k.substr(1);
}
return k;
};
values = {

@@ -66,2 +75,7 @@ 'null': null,

}
if (v[0] === '|') {
return key(v);
} else if (v[v.length - 1] === '|') {
return v.substr(0, v.length - 1);
}
if (!isNaN(parseFloat(v))) {

@@ -84,7 +98,7 @@ return parseFloat(v);

} else {
return makeObject(t)[k] = value(v);
return makeObject(t)[key(k)] = value(v);
}
} else {
t.o[k] = value(v);
return t.l = k;
t.o[key(k)] = value(v);
return t.l = key(k);
}

@@ -111,5 +125,5 @@ };

if (v != null) {
o[k] = value(v);
o[key(k)] = value(v);
} else {
o.push(k);
o.push(value(k));
}

@@ -116,0 +130,0 @@ return o;

@@ -48,3 +48,3 @@

stringify = function(obj, options) {
var colors, indstr, opt, pretty, s, toStr;
var colors, escape, indstr, opt, pretty, s, toStr;
if (options == null) {

@@ -62,2 +62,15 @@ options = {};

}
escape = function(k) {
var ref, ref1;
if ((ref = k[0]) === ' ' || ref === '#' || ref === '|') {
k = '|' + k;
}
if ((ref1 = k[k.length - 1]) === ' ' || ref1 === '#' || ref1 === '|') {
k += '|';
}
if (k === '') {
k = '||';
}
return k;
};
pretty = function(o, ind, visited) {

@@ -82,2 +95,6 @@ var j, k, keyValue, kl, l, len, maxKey, ref, v;

s = ind;
k = escape(k);
if (k.indexOf(' ') > 0 && k[0] !== '|') {
k = "|" + k + "|";
}
if (opt.align) {

@@ -130,3 +147,3 @@ ks = _.padRight(k, Math.max(maxKey, k.length + 2));

if (t === 'string') {
return colors.string(o);
return colors.string(escape(o));
} else if (t === 'object') {

@@ -133,0 +150,0 @@ if (opt.circular) {

{
"name": "noon",
"version": "0.4.5",
"version": "0.5.1",
"description": "'nother ordinary object notation",
"main": "js/main.js",
"keywords": [
"nother",
"noon",
"ordinary",
"object",
"notation"
"notation",
"json",
"cson",
"yaml"
],

@@ -12,0 +15,0 @@ "author": "monsterkodi",

@@ -19,23 +19,40 @@ # noon

- **only dictionary values can contain consecutive spaces**:
```coffee-scrip
```coffee-script
key 1 value 1
key 2 value 2 contains spaces
```
- **only 'malformed' strings need to be escaped**:
```coffee-script
a | leading spaces
b trailing spaces |
c | leading and trailing spaces |
pipe symbol |||
empty string ||
```
- **keys can also be escaped but can't contain the pipe symbol**:
```coffee-script
| leading| key has leading spaces
|trailing | key has trailing spaces
| both |
|mul ti|
| | key consists of spaces
|| key is empty string
```
- **objects inside lists** are expressed like this:
```coffee-script
.
a 1
.
b 2
.
a 1
.
b 2
```
- **dense notation**:
```coffee-script
key . a .. b . c
key . a .. b . c
```
is equivalent to
```coffee-script
key
a
b
c
key
a
b
c
```

@@ -48,3 +65,3 @@

- fast to parse
- no need to escape characters
- normally no need to escape characters

@@ -51,0 +68,0 @@ #### disadvantages

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