canonicaljson
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bignumber.js')) : | ||
typeof define === 'function' && define.amd ? define(['bignumber.js'], factory) : | ||
(factory(global.BigNumber)); | ||
}(this, (function (BigNumber) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('bignumber.js')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'bignumber.js'], factory) : | ||
(factory((global.CanonicalJSON = {}),global.BigNumber)); | ||
}(this, (function (exports,BigNumber) { 'use strict'; | ||
BigNumber = BigNumber && BigNumber.hasOwnProperty('default') ? BigNumber['default'] : BigNumber; | ||
/* | ||
Copyright 2017 Stratumn SAS. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
// Regular expressions that matches characters otherwise inexpressible in JSON (U+0022 QUOTATION MARK, U+005C REVERSE SOLIDUS, and ASCII control characters U+0000 through U+001F) or UTF-8 (U+D800 through U+DFFF) | ||
var forbidden = /(?:[\0-\x1F"\\]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/; | ||
@@ -572,2 +589,6 @@ | ||
var transformString = function (string) { | ||
if (!forbidden.test(string)) { | ||
return '"' + string + '"'; | ||
} | ||
var result = ''; | ||
@@ -911,10 +932,12 @@ | ||
https://github.com/mirkokiefer/canonical-json/blob/master/index.js | ||
Modifications were made to conform to the canonicaljson spec. | ||
Modifications were made to conform to the canonicaljson spec: | ||
https://github.com/gibson042/canonicaljson-spec | ||
*/ | ||
module.exports = { | ||
stringify: stringify, | ||
parse: parse }; | ||
exports.stringify = stringify; | ||
exports.parse = parse; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=canonicaljson.js.map |
{ | ||
"name": "canonicaljson", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0", | ||
"description": "JS library for producing JSON in canonical format", | ||
@@ -14,3 +14,3 @@ "main": "lib/canonicaljson.js", | ||
"scripts": { | ||
"build": "rollup -c rollup.es.config.js && rollup -c rollup.umd.config.js", | ||
"build": "rollup -c rollup.config.js", | ||
"pretest:integration": "npm run build", | ||
@@ -17,0 +17,0 @@ "test:unit": "jest --coverage", |
# canonicaljson-js | ||
JS library for producing JSON in canonical format as specified by https://gibson042.github.io/canonicaljson-spec/. The provided interface matches that of native JSON object. | ||
[![npm](https://img.shields.io/npm/v/canonicaljson.svg)](https://www.npmjs.com/package/canonicaljson) | ||
[![build status](https://travis-ci.org/stratumn/canonicaljson-js.svg?branch=master)](https://travis-ci.org/stratumn/canonicaljson-js) | ||
@@ -9,13 +11,15 @@ [![codecov](https://codecov.io/gh/stratumn/canonicaljson-js/branch/master/graph/badge.svg)](https://codecov.io/gh/stratumn/canonicaljson-js) | ||
```bash | ||
npm install canonicaljson | ||
``` | ||
$ npm install canonicaljson | ||
``` | ||
or | ||
```bash | ||
yarn add canonicaljson | ||
``` | ||
$ yarn add canonicaljson | ||
``` | ||
## Usage | ||
``` | ||
```bash | ||
const json = require('canonicaljson'); | ||
@@ -36,2 +40,10 @@ | ||
Integration tests are located in the `canonicaljson-spec` submodule. | ||
To download them, you should run: | ||
```bash | ||
git submodule init | ||
git submodule update | ||
``` | ||
### macOS | ||
@@ -43,3 +55,4 @@ | ||
You can do, for instance: | ||
``` | ||
```bash | ||
brew install coreutils | ||
@@ -53,3 +66,3 @@ | ||
``` | ||
```bash | ||
brew install gawk | ||
@@ -60,3 +73,3 @@ ``` | ||
``` | ||
```bash | ||
sed -i "" s_/usr/bin/awk_/usr/local/bin/gawk_ canonicaljson-spec/test/prettyjson.awk | ||
@@ -66,2 +79,1 @@ ``` | ||
This change will be ignored by `git`. | ||
@@ -0,1 +1,18 @@ | ||
/* | ||
Copyright 2017 Stratumn SAS. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
// Regular expressions that matches characters otherwise inexpressible in JSON (U+0022 QUOTATION MARK, U+005C REVERSE SOLIDUS, and ASCII control characters U+0000 through U+001F) or UTF-8 (U+D800 through U+DFFF) | ||
export default /[\u0022\u005c\u0000-\u001F\ud800-\udfff]/u; |
@@ -20,3 +20,4 @@ /* | ||
https://github.com/mirkokiefer/canonical-json/blob/master/index.js | ||
Modifications were made to conform to the canonicaljson spec. | ||
Modifications were made to conform to the canonicaljson spec: | ||
https://github.com/gibson042/canonicaljson-spec | ||
*/ | ||
@@ -27,5 +28,2 @@ | ||
module.exports = { | ||
stringify, | ||
parse | ||
}; | ||
export { stringify, parse }; |
@@ -45,2 +45,6 @@ /* | ||
export default function(string) { | ||
if (!forbidden.test(string)) { | ||
return `"${string}"`; | ||
} | ||
let result = ''; | ||
@@ -47,0 +51,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
160324
2150
1
74
1