json-replace-exponentials
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -15,4 +15,6 @@ #!/usr/bin/env node | ||
// https://github.com/import-js/eslint-plugin-import/issues/2844 | ||
// eslint-disable-next-line import/extensions | ||
const jsonReplaceExponentials = require('..'); | ||
const packageJson = require('../package.json'); | ||
const jsonReplaceExponentials = require('..'); | ||
@@ -22,3 +24,3 @@ /** Options for command entry points. | ||
* @typedef {{ | ||
* env: !object<string,string>, | ||
* env: !Object<string,string>, | ||
* stdin: !module:stream.Readable, | ||
@@ -28,3 +30,3 @@ * stdout: !module:stream.Writable, | ||
* }} CommandOptions | ||
* @property {!object<string,string>} env Environment variables. | ||
* @property {!Object<string,string>} env Environment variables. | ||
* @property {!module:stream.Readable} stdin Stream from which input is read. | ||
@@ -71,3 +73,3 @@ * @property {!module:stream.Writable} stdout Stream to which output is | ||
stdout.write(usage); | ||
process.nextTick(callback, 0); | ||
queueMicrotask(() => callback(0)); | ||
return; | ||
@@ -78,3 +80,3 @@ | ||
stdout.write(`${packageJson.name} ${packageJson.version}\n`); | ||
process.nextTick(callback, 0); | ||
queueMicrotask(() => callback(0)); | ||
return; | ||
@@ -88,3 +90,3 @@ | ||
stderr.write(`Error: Unexpected arguments.\n${usage}`); | ||
process.nextTick(callback, 1); | ||
queueMicrotask(() => callback(1)); | ||
return; | ||
@@ -91,0 +93,0 @@ } |
15
index.js
@@ -22,3 +22,3 @@ /** | ||
const stringPattern = | ||
'"(?:[^\x00-\x1F\\\\"]|\\\\(?:["\\\\/bfnrt]|u[0-9a-fA-F]{4}))*"'; | ||
'"(?:[^\\x00-\\x1F\\\\"]|\\\\(?:["\\\\/bfnrt]|u[0-9a-fA-F]{4}))*"'; | ||
@@ -32,3 +32,4 @@ /** RegExp for JSON number in exponential notation occurring after after any | ||
const jsonWithNumberExpRE = | ||
new RegExp(`((?:${stringPattern}|[^"])*?)(${numberExpPattern})`, 'gy'); | ||
// eslint-disable-next-line regexp/no-control-character | ||
new RegExp(`((?:${stringPattern}|[^"0-9])*?)(${numberExpPattern})`, 'gy'); | ||
@@ -107,3 +108,9 @@ /** Converts the parts of a number in exponential notation to fixed-point | ||
function exponentialToFixedReplacer( | ||
match, prefix, numExp, signPart, intPart, fracPart, expPart, | ||
match, | ||
prefix, | ||
numExp, | ||
signPart, | ||
intPart, | ||
fracPart, | ||
expPart, | ||
) { | ||
@@ -151,3 +158,3 @@ // Limit exponent to mitigate issues due to large fixed-point representations | ||
jsonWithNumberExpRE.lastIndex = 0; | ||
return json.replace(jsonWithNumberExpRE, wrapReplacer); | ||
return json.replaceAll(jsonWithNumberExpRE, wrapReplacer); | ||
}; |
{ | ||
"name": "json-replace-exponentials", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Replace numbers in exponential notation by numbers in fixed-point notation (or anything else) in a string of JSON.", | ||
@@ -26,3 +26,4 @@ "keywords": [ | ||
"exports": { | ||
".": "./index.js" | ||
".": "./index.js", | ||
"./package.json": "./package.json" | ||
}, | ||
@@ -44,9 +45,7 @@ "bin": { | ||
"postversion": "rimraf doc && git clone -b gh-pages -l -q . doc && npm run doc && git -C doc add . && git -C doc commit -n -m \"Docs for v$npm_package_version\"", | ||
"preversion": "npm run test-cov && nyc check-coverage --statements 95 && depcheck --ignore-dirs doc && david && git-branch-is main && hub-ci-status -vv --wait", | ||
"preversion": "npm run test-cov && c8 check-coverage --statements 95 && depcheck --ignore-dirs doc --ignores=\"eslint-*,rimraf\" && david && git-branch-is main && hub-ci-status -vv --wait", | ||
"test": "npm run lint && npm run test-unit", | ||
"test-cov": "npm run lint && npm run test-unit-cov", | ||
"test-unit": "node --throw-deprecation --unhandled-rejections=strict node_modules/mocha/bin/mocha --parallel --recursive test", | ||
"//": "Note: nyc incompatible with --parallel. See https://github.com/istanbuljs/nyc/issues/1328 and https://github.com/mochajs/mocha/issues/4372", | ||
"test-unit-cov": "nyc --reporter=lcov --reporter=text node --throw-deprecation --unhandled-rejections=strict node_modules/mocha/bin/mocha --recursive test", | ||
"upload-cov": "codecov < ./coverage/lcov.info && coveralls < ./coverage/lcov.info", | ||
"test-unit": "node --throw-deprecation --unhandled-rejections=strict node_modules/mocha/bin/mocha.js --parallel --recursive test", | ||
"test-unit-cov": "c8 --reporter=lcov --reporter=text npm run test-unit", | ||
"version": "npm run changelog && echo && echo === Please edit CHANGELOG.md as desired, then exit === && echo && \"${npm_config_shell:-${SHELL:-bash}}\" && git commit -m \"Update CHANGELOG.md for $npm_package_version\" CHANGELOG.md", | ||
@@ -56,20 +55,19 @@ "version-deps": "npm install conventional-changelog-cli david depcheck git-branch-is hub-ci-status" | ||
"devDependencies": { | ||
"@kevinoid/eslint-config": "^16.0.0", | ||
"codecov": "^3.0.0", | ||
"coveralls": "^3.0.0", | ||
"eslint": "^7.3.0", | ||
"eslint-config-airbnb-base": "^14.2.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jsdoc": "^32.0.0", | ||
"eslint-plugin-node": "^11.0.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-unicorn": "^29.0.0", | ||
"jsdoc": "^3.6.0", | ||
"mocha": "^8.0.1", | ||
"@kevinoid/eslint-config": "^31.1.0", | ||
"c8": "^8.0.0", | ||
"eslint": "^8.38.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"eslint-plugin-jsdoc": "^46.0.0", | ||
"eslint-plugin-n": "^16.0.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"eslint-plugin-regexp": "^1.0.0", | ||
"eslint-plugin-unicorn": "^48.0.1", | ||
"jsdoc": "^4.0.0", | ||
"mocha": "^10.0.0", | ||
"nodecat": "^2.0.0", | ||
"nyc": "^15.0.0", | ||
"rimraf": "^3.0.0" | ||
"rimraf": "^5.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=10.17", | ||
"node": ">=16", | ||
"npm": ">=1.3.7" | ||
@@ -84,4 +82,5 @@ }, | ||
"eslint-plugin-jsdoc", | ||
"eslint-plugin-node", | ||
"eslint-plugin-n", | ||
"eslint-plugin-promise", | ||
"eslint-plugin-regexp", | ||
"eslint-plugin-unicorn" | ||
@@ -94,4 +93,5 @@ ] | ||
}, | ||
"nyc": { | ||
"c8": { | ||
"exclude": [ | ||
"benchmark", | ||
"test" | ||
@@ -98,0 +98,0 @@ ] |
json-replace-exponentials | ||
========================= | ||
[![Build Status](https://img.shields.io/github/workflow/status/kevinoid/json-replace-exponentials/Node.js%20CI/main.svg?style=flat&label=build)](https://github.com/kevinoid/json-replace-exponentials/actions?query=branch%3Amain) | ||
[![Coverage](https://img.shields.io/codecov/c/github/kevinoid/json-replace-exponentials.svg?style=flat)](https://codecov.io/github/kevinoid/json-replace-exponentials?branch=main) | ||
[![Dependency Status](https://img.shields.io/david/kevinoid/json-replace-exponentials.svg?style=flat)](https://david-dm.org/kevinoid/json-replace-exponentials) | ||
[![Build Status](https://img.shields.io/github/actions/workflow/status/kevinoid/json-replace-exponentials/node.js.yml?branch=main&style=flat&label=build)](https://github.com/kevinoid/json-replace-exponentials/actions?query=branch%3Amain) | ||
[![Coverage](https://img.shields.io/codecov/c/github/kevinoid/json-replace-exponentials/main.svg?style=flat)](https://app.codecov.io/gh/kevinoid/json-replace-exponentials/branch/main) | ||
[![Dependency Status](https://img.shields.io/librariesio/release/npm/json-replace-exponentials.svg?style=flat)](https://libraries.io/npm/json-replace-exponentials) | ||
[![Supported Node Version](https://img.shields.io/node/v/json-replace-exponentials.svg?style=flat)](https://www.npmjs.com/package/json-replace-exponentials) | ||
@@ -8,0 +8,0 @@ [![Version on NPM](https://img.shields.io/npm/v/json-replace-exponentials.svg?style=flat)](https://www.npmjs.com/package/json-replace-exponentials) |
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
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
14
252
18087
5