typographic-currency
Advanced tools
Comparing version 0.1.7 to 1.1.0
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = typographicCurrency; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _typographicCurrencyDb = require('typographic-currency-db'); | ||
@@ -13,19 +12,13 @@ | ||
exports['default'] = function (input) { | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var text = null; | ||
var pattern = function pattern(key) { | ||
return new RegExp('([^a-z]|\\b)(' + key + ')\\b', 'gi'); | ||
}; | ||
for (var key in _typographicCurrencyDb2['default']) { | ||
var currentKey = _typographicCurrencyDb2['default'][key]; | ||
// use global and ignore letter case | ||
var pattern = new RegExp('([^a-z]|\\b)(' + key + ')\\b', 'gi'); | ||
var textInput = text ? text : input; | ||
text = textInput.replace(pattern, '$1' + currentKey); | ||
} | ||
return text; | ||
function typographicCurrency(input) { | ||
if (!input) return; | ||
return Object.keys(_typographicCurrencyDb2.default).reduce(function (state, key) { | ||
return state.replace(pattern(key), '$1' + _typographicCurrencyDb2.default[key]); | ||
}, input); | ||
}; | ||
module.exports = exports['default']; | ||
21
index.js
@@ -1,17 +0,10 @@ | ||
import currencyDB from 'typographic-currency-db'; | ||
import db from 'typographic-currency-db'; | ||
export default (input) => { | ||
const pattern = key => new RegExp(`([^a-z]|\\b)(${key})\\b`, 'gi'); | ||
let text = null; | ||
for (var key in currencyDB) { | ||
const currentKey = currencyDB[key]; | ||
// use global and ignore letter case | ||
const pattern = new RegExp(`([^a-z]|\\b)(${key})\\b`, 'gi'); | ||
let textInput = (text) ? text : input; | ||
text = textInput.replace(pattern, `$1${currentKey}`); | ||
} | ||
return text; | ||
export default function typographicCurrency(input) { | ||
if (!input) return; | ||
return Object.keys(db).reduce((state, key) => { | ||
return state.replace(pattern(key), `$1${db[key]}`); | ||
}, input); | ||
}; |
{ | ||
"name": "typographic-currency", | ||
"version": "0.1.7", | ||
"version": "1.1.0", | ||
"description": "Use the correct symbol of currency", | ||
"main": "index.es5.js", | ||
"scripts": { | ||
"coverage": "isparta cover _mocha index.js -- --require babel/register", | ||
"watch": "npm run transpile -- --watch", | ||
"coverage": "babel-node ./node_modules/.bin/isparta cover _mocha index.js -- --compilers js:babel-core/register", | ||
"precoveralls": "npm run coverage", | ||
"coveralls": "coveralls < coverage/lcov.info", | ||
"test": "mocha --require babel/register", | ||
"test": "mocha --require babel-core/register", | ||
"tdd": "npm test -- --watch", | ||
"transpile": "babel index.js > index.es5.js", | ||
"transpile": "babel index.js --out-file index.es5.js", | ||
"prepublish": "npm run transpile", | ||
"clean": "trash index.es5.js", | ||
"clean": "rimraf index.es5.js", | ||
"push": "git push --follow-tags", | ||
@@ -28,2 +29,6 @@ "postpublish": "npm-run-all clean push" | ||
"author": "talgautb <gtalk.kz@gmail.com> (http://gtalk.kz)", | ||
"maintainers": [ | ||
"talgautb <gtalk.kz@gmail.com> (http://gtalk.kz)", | ||
"Vladimir Starkov <iamstarkov@gmail.com> (https://iamstarkov.com/)" | ||
], | ||
"license": "MIT", | ||
@@ -36,8 +41,10 @@ "bugs": { | ||
"assert": "*", | ||
"babel": "*", | ||
"babel-cli": "^6.2.0", | ||
"babel-core": "^6.2.1", | ||
"babel-preset-es2015": "^6.1.18", | ||
"coveralls": "*", | ||
"isparta": "*", | ||
"isparta": "^4.0.0", | ||
"mocha": "*", | ||
"npm-run-all": "*", | ||
"trash": "*" | ||
"rimraf": "*" | ||
}, | ||
@@ -44,0 +51,0 @@ "dependencies": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
4641
9
0
9
32
1