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

make-plural

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-plural - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

18

lib/make-plural.js

@@ -98,4 +98,5 @@ (function () {

exports.build = function(lc, op_function) {
var fn_body = [], symbols = {}, tests = {};
exports.build = function(lc, opt) {
var fn, fn_str, lines = [], symbols = {}, tests = {};
if (!opt) opt = {};
if (!rules) exports.set_rules();

@@ -107,12 +108,15 @@ if (!rules[lc]) { console.error('ERROR: locale "' + lc + '" not found'); return null; }

cond = parts.shift().trim();
if (cond) fn_body.push('if (' + parse(cond, symbols) + ') return \'' + key + '\';');
if (cond) lines.push('if (' + parse(cond, symbols) + ') return \'' + key + '\';');
tests[key] = test_values(parts.join(' '));
}
fn_body.unshift(vars(symbols));
fn_body.push('return \'other\';');
var fn = new Function('n', fn_body.join('\n').trim());
lines.unshift(vars(symbols));
lines.push('return \'other\';');
fn = new Function('n', lines.join('\n').trim());
if (!test(fn, tests)) return null;
return op_function ? fn : 'function(n) {\n ' + fn_body.join('\n ').trim() + '\n}';
if (opt['return_function']) return fn;
fn_str = 'function(n) {\n ' + lines.join('\n ') + '\n}';
if (opt['minify']) fn_str = fn_str.replace(/\s+/g, '').replace(/{var/, '{var ');
return fn_str;
};
})();
{
"name": "make-plural",
"version": "1.0.0",
"version": "1.1.0",
"description": "Translates Unicode CLDR pluralization rules to executable JavaScript",

@@ -5,0 +5,0 @@ "keywords": ["unicode", "CLDR", "i18n", "internationalization", "pluralization"],

@@ -40,3 +40,3 @@ make-plural.js

> sk = plurals.build('sk', true)
> sk = plurals.build('sk', {'return_function':1})
[Function]

@@ -60,6 +60,9 @@

### build(lc, op_function)
### build(lc, opt)
By default, returns a string representation of a function that takes a single
argument `n` and returns its plural category for the given locale `lc`. If
`op_function` is `true`, it returns an executable function instead.
argument `n` and returns its plural category for the given locale `lc`. The
optional `opt` object may contain the following members:
* `return_function` -- if true, `build` returns an executable function of `n`
rather than a string
* `minify` -- if true, the string output of `build` is minified

@@ -66,0 +69,0 @@ ### set_rules(cldr)

Sorry, the diff of this file is not supported yet

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