@csson/csson
Advanced tools
Comparing version 0.2.0 to 0.3.0
#!/usr/bin/env node | ||
const fs = require('fs') | ||
const csson = require('../index.cjs.js') | ||
const csson = require('../index.cjs') | ||
@@ -5,0 +5,0 @@ const file = process.argv.slice(2)[0] |
@@ -71,3 +71,2 @@ import * as parseCSS from './lib/parse-css/index.js' | ||
} | ||
toJSON() { return JSON.stringify(this.value) } | ||
} | ||
@@ -74,0 +73,0 @@ |
{ | ||
"name": "@csson/csson", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "A JSON superset with additional types from CSS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,3 +11,3 @@ # CSSON | ||
> * a superset of JSON as far as tested - CSS character escapes and JSON string escapes may overlap in a mutually exclusive way in the current implementation — if you know how to verif this, test this, or support this, please open an issue and report any bugs you find! | ||
> \* a superset of JSON as far as tested - CSS character escapes and JSON string escapes may overlap in a mutually exclusive way in the current implementation — if you know how to verify this, test this, or support this, please open an issue and report any bugs you find! | ||
@@ -141,3 +141,3 @@ ## Comments | ||
- [index.js](./index.js) is an ES module for use with [Deno](https://deno.land/), [QuickJS](https://bellard.org/quickjs), browsers, and ES module bundlers | ||
- [index.cjs.js](./index.cjs.js) is a CommonJS module for use with [Node](https://nodejs.org/en/) and CommonJS bundlers | ||
- [index.cjs](./index.cjs) is a CommonJS module for use with [Node](https://nodejs.org/en/) and CommonJS bundlers | ||
@@ -176,3 +176,3 @@ Below are some of the ways you can consume and use this package. | ||
```js | ||
const CSSON = require('@csson/csson/index.cjs.js') | ||
const CSSON = require('@csson/csson/index.cjs') | ||
@@ -179,0 +179,0 @@ console.log( |
@@ -1,2 +0,2 @@ | ||
const csson = require('../index.cjs.js') | ||
const csson = require('../index.cjs') | ||
@@ -21,2 +21,7 @@ const tests = [ | ||
[ | ||
csson`<xml>oops</xml>`, | ||
undefined, | ||
'bad input returns undefined' | ||
], | ||
[ | ||
csson`${1+1}`.toString(), | ||
@@ -55,2 +60,7 @@ '2', | ||
], | ||
[ | ||
JSON.stringify(csson`1`), | ||
"1", | ||
'JSON.stringify(csson`1`) is "1"' | ||
], | ||
@@ -83,2 +93,7 @@ // <json-true> | ||
], | ||
[ | ||
JSON.stringify(csson`true`), | ||
"true", | ||
'JSON.stringify(csson`true`) is "true"' | ||
], | ||
@@ -111,2 +126,7 @@ // <json-false> | ||
], | ||
[ | ||
JSON.stringify(csson`false`), | ||
"false", | ||
'JSON.stringify(csson`false`) is "false"' | ||
], | ||
@@ -139,2 +159,7 @@ // <json-null> | ||
], | ||
[ | ||
JSON.stringify(csson`null`), | ||
'null', | ||
'JSON.stringify(csson`null`) is "null"' | ||
], | ||
@@ -160,8 +185,13 @@ // <json-string> | ||
'"hello"', | ||
'csson`"hello"`.toString() is a "hello"' | ||
'csson`"hello"`.toString() is "hello"' | ||
], | ||
[ | ||
csson`"hello"`.toJSON(), | ||
'hello', | ||
'csson`"hello"`.toJSON() is a string hello' | ||
], | ||
[ | ||
JSON.stringify(csson`"hello"`), | ||
'"hello"', | ||
'csson`"hello"`.toJSON() is a string "hello"' | ||
'JSON.stringify(csson`"hello"`) is a string "hello"' | ||
], | ||
@@ -195,2 +225,7 @@ | ||
], | ||
[ | ||
JSON.stringify(csson`hello`), | ||
'"hello"', | ||
'JSON.stringify(csson`hello`) is a string "hello"' | ||
], | ||
@@ -223,2 +258,7 @@ // <css-hash> | ||
], | ||
[ | ||
JSON.stringify(csson`#hash`), | ||
'"#hash"', | ||
'JSON.stringify(csson`#hash`) is a string "#hash"' | ||
], | ||
@@ -301,2 +341,17 @@ // <css-url> | ||
], | ||
[ | ||
JSON.stringify(csson`url(unquoted)`), | ||
'"unquoted"', | ||
'JSON.stringify(csson`url(unquoted)`) is a string "unquoted"' | ||
], | ||
[ | ||
JSON.stringify(csson`url('single')`), | ||
'"single"', | ||
`JSON.stringify(csson\`url('single')\`) is a string "single"` | ||
], | ||
[ | ||
JSON.stringify(csson`url("double")`), | ||
'"double"', | ||
'JSON.stringify(csson`url("double")`) is a string "double"' | ||
], | ||
@@ -329,2 +384,7 @@ // <json-array> | ||
], | ||
[ | ||
JSON.stringify(csson`[1, 2, 3]`), | ||
'[1,2,3]', | ||
'JSON.stringify(csson`[1, 2, 3]`) is an "[1,2,3]"' | ||
], | ||
@@ -353,6 +413,11 @@ // <csson-array> | ||
[ | ||
Array.isArray(csson`[1, 2, 3]`.toJSON()), | ||
Array.isArray(csson`[one, #two, url(three)]`.toJSON()), | ||
true, | ||
'csson`[1, 2, 3]`.toJSON() is an array' | ||
'csson`[one, #two, url(three)]`.toJSON() is an array' | ||
], | ||
[ | ||
JSON.stringify(csson`[one, #two, url(three)]`), | ||
'["one","#two","three"]', | ||
`JSON.stringify(csson\`[one, #two, url(three)]\`) is '["one","#two","three"]'` | ||
], | ||
@@ -385,2 +450,7 @@ // <json-object> | ||
], | ||
[ | ||
JSON.stringify(csson`{"one": 1,"two":2}`), | ||
'{"one":1,"two":2}', | ||
`JSON.stringify(csson\`{"one":1,"two":2}\`) is '{"one":1,"two":2}'` | ||
], | ||
@@ -413,2 +483,7 @@ // <csson-object> | ||
], | ||
[ | ||
JSON.stringify(csson`{one: 1, two: 2}`), | ||
'{"one":1,"two":2}', | ||
`JSON.stringify(csson\`{one: 1, two: 2}\`) is '{"one":1,"two":2}'` | ||
], | ||
@@ -439,4 +514,9 @@ // <css-qualified-rule> | ||
'{"a":{"b":"c"}}', | ||
'csson`a { b: c; }`.toJSON() is a string "{"a":{"b":"c"}}"' | ||
'csson`a { b: c; }`.toJSON() is {a: {b: "c"}}' | ||
], | ||
[ | ||
JSON.stringify(csson`a { b: c; }`), | ||
'{"a":{"b":"c"}}', | ||
'JSON.stringify(csson`a { b: c; }`.toJSON()) is "{"a":{"b":"c"}}"' | ||
], | ||
@@ -515,3 +595,3 @@ // CSSON Features | ||
console.log(`\nSuccessful: ${passed.length}/${tests.length}\n`) | ||
passed.forEach(([a, b, message]) => console.log(a === b, message)) | ||
//passed.forEach(([a, b, message]) => console.log(a === b, message)) | ||
@@ -518,0 +598,0 @@ if (failed.length) { |
@@ -21,2 +21,7 @@ import csson from '../index.js' | ||
[ | ||
csson`<xml>oops</xml>`, | ||
undefined, | ||
'bad input returns undefined' | ||
], | ||
[ | ||
csson`${1+1}`.toString(), | ||
@@ -55,2 +60,7 @@ '2', | ||
], | ||
[ | ||
JSON.stringify(csson`1`), | ||
"1", | ||
'JSON.stringify(csson`1`) is "1"' | ||
], | ||
@@ -83,2 +93,7 @@ // <json-true> | ||
], | ||
[ | ||
JSON.stringify(csson`true`), | ||
"true", | ||
'JSON.stringify(csson`true`) is "true"' | ||
], | ||
@@ -111,2 +126,7 @@ // <json-false> | ||
], | ||
[ | ||
JSON.stringify(csson`false`), | ||
"false", | ||
'JSON.stringify(csson`false`) is "false"' | ||
], | ||
@@ -139,2 +159,7 @@ // <json-null> | ||
], | ||
[ | ||
JSON.stringify(csson`null`), | ||
'null', | ||
'JSON.stringify(csson`null`) is "null"' | ||
], | ||
@@ -160,8 +185,13 @@ // <json-string> | ||
'"hello"', | ||
'csson`"hello"`.toString() is a "hello"' | ||
'csson`"hello"`.toString() is "hello"' | ||
], | ||
[ | ||
csson`"hello"`.toJSON(), | ||
'hello', | ||
'csson`"hello"`.toJSON() is a string hello' | ||
], | ||
[ | ||
JSON.stringify(csson`"hello"`), | ||
'"hello"', | ||
'csson`"hello"`.toJSON() is a string "hello"' | ||
'JSON.stringify(csson`"hello"`) is a string "hello"' | ||
], | ||
@@ -195,2 +225,7 @@ | ||
], | ||
[ | ||
JSON.stringify(csson`hello`), | ||
'"hello"', | ||
'JSON.stringify(csson`hello`) is a string "hello"' | ||
], | ||
@@ -223,2 +258,7 @@ // <css-hash> | ||
], | ||
[ | ||
JSON.stringify(csson`#hash`), | ||
'"#hash"', | ||
'JSON.stringify(csson`#hash`) is a string "#hash"' | ||
], | ||
@@ -301,2 +341,17 @@ // <css-url> | ||
], | ||
[ | ||
JSON.stringify(csson`url(unquoted)`), | ||
'"unquoted"', | ||
'JSON.stringify(csson`url(unquoted)`) is a string "unquoted"' | ||
], | ||
[ | ||
JSON.stringify(csson`url('single')`), | ||
'"single"', | ||
`JSON.stringify(csson\`url('single')\`) is a string "single"` | ||
], | ||
[ | ||
JSON.stringify(csson`url("double")`), | ||
'"double"', | ||
'JSON.stringify(csson`url("double")`) is a string "double"' | ||
], | ||
@@ -329,2 +384,7 @@ // <json-array> | ||
], | ||
[ | ||
JSON.stringify(csson`[1, 2, 3]`), | ||
'[1,2,3]', | ||
'JSON.stringify(csson`[1, 2, 3]`) is an "[1,2,3]"' | ||
], | ||
@@ -353,6 +413,11 @@ // <csson-array> | ||
[ | ||
Array.isArray(csson`[1, 2, 3]`.toJSON()), | ||
Array.isArray(csson`[one, #two, url(three)]`.toJSON()), | ||
true, | ||
'csson`[1, 2, 3]`.toJSON() is an array' | ||
'csson`[one, #two, url(three)]`.toJSON() is an array' | ||
], | ||
[ | ||
JSON.stringify(csson`[one, #two, url(three)]`), | ||
'["one","#two","three"]', | ||
`JSON.stringify(csson\`[one, #two, url(three)]\`) is '["one","#two","three"]'` | ||
], | ||
@@ -385,2 +450,7 @@ // <json-object> | ||
], | ||
[ | ||
JSON.stringify(csson`{"one": 1,"two":2}`), | ||
'{"one":1,"two":2}', | ||
`JSON.stringify(csson\`{"one":1,"two":2}\`) is '{"one":1,"two":2}'` | ||
], | ||
@@ -413,2 +483,7 @@ // <csson-object> | ||
], | ||
[ | ||
JSON.stringify(csson`{one: 1, two: 2}`), | ||
'{"one":1,"two":2}', | ||
`JSON.stringify(csson\`{one: 1, two: 2}\`) is '{"one":1,"two":2}'` | ||
], | ||
@@ -439,4 +514,9 @@ // <css-qualified-rule> | ||
'{"a":{"b":"c"}}', | ||
'csson`a { b: c; }`.toJSON() is a string "{"a":{"b":"c"}}"' | ||
'csson`a { b: c; }`.toJSON() is {a: {b: "c"}}' | ||
], | ||
[ | ||
JSON.stringify(csson`a { b: c; }`), | ||
'{"a":{"b":"c"}}', | ||
'JSON.stringify(csson`a { b: c; }`.toJSON()) is "{"a":{"b":"c"}}"' | ||
], | ||
@@ -515,3 +595,3 @@ // CSSON Features | ||
console.log(`\nSuccessful: ${passed.length}/${tests.length}\n`) | ||
passed.forEach(([a, b, message]) => console.log(a === b, message)) | ||
//passed.forEach(([a, b, message]) => console.log(a === b, message)) | ||
@@ -518,0 +598,0 @@ if (failed.length) { |
Sorry, the diff of this file is not supported yet
164737
5717