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.2.2 to 1.3.0

6

dist/index.js

@@ -114,7 +114,7 @@ 'use strict';

// all words found in number phrases
var NUMBER_WORDS = ['and', 'point'].concat((0, _keys2.default)(UNIT)).concat((0, _keys2.default)(TEN)).concat((0, _keys2.default)(MAGNITUDE));
var NUMBER_WORDS = ['and', 'point', 'dot'].concat((0, _keys2.default)(UNIT)).concat((0, _keys2.default)(TEN)).concat((0, _keys2.default)(MAGNITUDE));
var PUNCTUATION = /[.,\/#!$%\^&\*;:{}=\-_`~()]/g;
var grammar = _ohmJs2.default.grammar('\n WordsToNumbers {\n Number = Section* "point"? 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 = ' + (0, _keys2.default)(TEN).map(function (key) {
return '"' + key + '" | ';

@@ -213,3 +213,3 @@ }).join('').slice(0, -2) + '\n unit = ' + (0, _keys2.default)(UNIT).map(function (key) {

if (!regions.length) return [word];
if (word.text === 'point') {
if (word.text === 'point' || word.text === 'dot') {
var newRegions = regions.slice();

@@ -216,0 +216,0 @@ newRegions[regions.length - 1].pointReached = true;

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

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

@@ -209,1 +209,5 @@ /* eslint-disable no-unused-expressions */

});
it('eleven dot one', () => {
expect(wtn('eleven dot one')).to.eq(11.1);
});

@@ -90,3 +90,3 @@ /* Node module for converting words to numerals.

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

@@ -100,3 +100,3 @@ .concat(Object.keys(TEN))

WordsToNumbers {
Number = Section* "point"? unit*
Number = Section* ("point" | "dot")? unit*
Section = TenAndMagnitude | UnitAndMagnitude | TenUnitAndMagnitude | Unit | Ten | TenAndUnit | Magnitude

@@ -181,3 +181,3 @@ Ten = ten ~unit ~magnitude

if (!regions.length) return [word];
if (word.text === 'point') {
if (word.text === 'point' || word.text === 'dot') {
const newRegions = regions.slice();

@@ -184,0 +184,0 @@ newRegions[regions.length - 1].pointReached = true;

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