words-to-numbers
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -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; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
40947
1061
0
10212