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

words-to-numbers

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

words-to-numbers - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

18

dist/index.js

@@ -113,12 +113,16 @@ 'use strict';

var UNIT_KEYS = (0, _keys2.default)(UNIT);
var TEN_KEYS = (0, _keys2.default)(TEN);
var MAGNITUDE_KEYS = (0, _keys2.default)(MAGNITUDE);
// all words found in number phrases
var NUMBER_WORDS = ['and', 'point', 'dot'].concat((0, _keys2.default)(UNIT)).concat((0, _keys2.default)(TEN)).concat((0, _keys2.default)(MAGNITUDE));
var NUMBER_WORDS = ['and', 'point', 'dot'].concat(UNIT_KEYS).concat(TEN_KEYS).concat(MAGNITUDE_KEYS);
var PUNCTUATION = /[.,\/#!$%\^&\*;:{}=\-_`~()]/g;
var grammar = _ohmJs2.default.grammar('\n WordsToNumbers {\n Number = Section* ("point" | "dot")? unit*\n Section = TenAndMagnitude | UnitAndMagnitude | TenUnitAndMagnitude | Unit | Ten | TenAndUnit | Magnitude\n Ten = ten ~unit ~magnitude\n TenAndUnit = ten unit ~magnitude\n TenAndMagnitude = ten ~unit magnitude\n UnitAndMagnitude = ~ten unit magnitude\n TenUnitAndMagnitude = ten unit magnitude\n Unit = ~ten unit ~magnitude\n Magnitude = ~ten ~unit magnitude\n ten = ' + (0, _keys2.default)(TEN).map(function (key) {
var grammar = _ohmJs2.default.grammar('\n WordsToNumbers {\n Number = Section* ("point" | "dot")? unit*\n Section = TenAndMagnitude | UnitAndMagnitude | TenUnitAndMagnitude | Unit | Ten | TenAndUnit | Magnitude\n Ten = ten ~unit ~magnitude\n TenAndUnit = ten unit ~magnitude\n TenAndMagnitude = ten ~unit magnitude\n UnitAndMagnitude = ~ten unit magnitude\n TenUnitAndMagnitude = ten unit magnitude\n Unit = ~ten unit ~magnitude\n Magnitude = ~ten ~unit magnitude\n ten = ' + TEN_KEYS.map(function (key) {
return '"' + key + '" | ';
}).join('').slice(0, -2) + '\n unit = ' + (0, _keys2.default)(UNIT).map(function (key) {
}).join('').slice(0, -2) + '\n unit = ' + UNIT_KEYS.map(function (key) {
return '"' + key + '" | ';
}).join('').slice(0, -2) + '\n magnitude = ' + (0, _keys2.default)(MAGNITUDE).map(function (key) {
}).join('').slice(0, -2) + '\n magnitude = ' + MAGNITUDE_KEYS.map(function (key) {
return '"' + key + '" | ';

@@ -185,9 +189,9 @@ }).join('').slice(0, -2) + '\n }\n');

var isUnit = function isUnit(word) {
return (0, _keys2.default)(UNIT).indexOf(word) !== -1;
return UNIT_KEYS.indexOf(word) !== -1;
};
var isTen = function isTen(word) {
return (0, _keys2.default)(TEN).indexOf(word) !== -1;
return TEN_KEYS.indexOf(word) !== -1;
};
var isMag = function isMag(word) {
return (0, _keys2.default)(MAGNITUDE).indexOf(word) !== -1;
return MAGNITUDE_KEYS.indexOf(word) !== -1;
};

@@ -194,0 +198,0 @@

{
"name": "words-to-numbers",
"description": "convert textual words to numbers with optional fuzzy text matching",
"version": "1.3.1",
"version": "1.3.2",
"license": "MIT",

@@ -6,0 +6,0 @@ "options": {

@@ -89,7 +89,11 @@ /* Node module for converting words to numerals.

const UNIT_KEYS = Object.keys(UNIT);
const TEN_KEYS = Object.keys(TEN);
const MAGNITUDE_KEYS = Object.keys(MAGNITUDE);
// all words found in number phrases
const NUMBER_WORDS = ['and', 'point', 'dot']
.concat(Object.keys(UNIT))
.concat(Object.keys(TEN))
.concat(Object.keys(MAGNITUDE));
.concat(UNIT_KEYS)
.concat(TEN_KEYS)
.concat(MAGNITUDE_KEYS);

@@ -109,5 +113,5 @@ const PUNCTUATION = /[.,\/#!$%\^&\*;:{}=\-_`~()]/g;

Magnitude = ~ten ~unit magnitude
ten = ${Object.keys(TEN).map(key => `"${key}" | `).join('').slice(0, -2)}
unit = ${Object.keys(UNIT).map(key => `"${key}" | `).join('').slice(0, -2)}
magnitude = ${Object.keys(MAGNITUDE).map(key => `"${key}" | `).join('').slice(0, -2)}
ten = ${TEN_KEYS.map(key => `"${key}" | `).join('').slice(0, -2)}
unit = ${UNIT_KEYS.map(key => `"${key}" | `).join('').slice(0, -2)}
magnitude = ${MAGNITUDE_KEYS.map(key => `"${key}" | `).join('').slice(0, -2)}
}

@@ -153,5 +157,5 @@ `);

const isUnit = word => Object.keys(UNIT).indexOf(word) !== -1;
const isTen = word => Object.keys(TEN).indexOf(word) !== -1;
const isMag = word => Object.keys(MAGNITUDE).indexOf(word) !== -1;
const isUnit = word => UNIT_KEYS.indexOf(word) !== -1;
const isTen = word => TEN_KEYS.indexOf(word) !== -1;
const isMag = word => MAGNITUDE_KEYS.indexOf(word) !== -1;

@@ -158,0 +162,0 @@ const findRegions = (text, fuzzy) => {

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