New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cloudflare/intl-core

Package Overview
Dependencies
Maintainers
19
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudflare/intl-core - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

12

CHANGELOG.md

@@ -6,3 +6,11 @@ # Change Log

<a name="1.1.0"></a>
<a name="1.1.1"></a>
## [1.1.1](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/intl-core@1.1.0...@cloudflare/intl-core@1.1.1) (2018-10-26)
**Note:** Version bump only for package @cloudflare/intl-core
<a name="1.1.0"></a>
# [1.1.0](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/intl-core@1.0.15...@cloudflare/intl-core@1.1.0) (2018-10-25)

@@ -18,3 +26,3 @@

<a name="1.0.15"></a>
<a name="1.0.15"></a>
## [1.0.15](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/intl-core@1.0.14...@cloudflare/intl-core@1.0.15) (2018-10-24)

@@ -21,0 +29,0 @@

@@ -0,1 +1,9 @@

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -13,2 +21,6 @@

import { mapValues } from 'lodash';
import pseudoloc from 'pseudoloc/index-browserify';
pseudoloc.option.delimiter = '%';
pseudoloc.option.startDelimiter = '{';
pseudoloc.option.endDelimiter = '}';

@@ -45,2 +57,6 @@ var Translator =

value: function createInstance(locale) {
if (this.options.pseudoLoc && this.options.phrases) {
this.options.phrases = this.psudoLocalizePhrases(this.options.phrases);
}
this.map[locale] = new Polyglot(Object.assign(this.options, {

@@ -51,2 +67,13 @@ locale: locale

}, {
key: "psudoLocalizePhrases",
value: function psudoLocalizePhrases(phrases) {
return Object.entries(phrases).reduce(function (acc, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
return Object.assign(acc, _defineProperty({}, key, pseudoloc.str(value)));
}, {});
}
}, {
key: "getInstance",

@@ -75,2 +102,7 @@ value: function getInstance(locale) {

var p = this.getInstance(locale);
if (this.options.pseudoLoc) {
phrases = this.psudoLocalizePhrases(phrases);
}
p.extend(phrases);

@@ -106,2 +138,6 @@ }

value: function replace(phrases) {
if (this.options.pseudoLoc) {
phrases = this.psudoLocalizePhrases(phrases);
}
this.getInstance().replace(phrases);

@@ -108,0 +144,0 @@ }

@@ -16,4 +16,14 @@ "use strict";

var _indexBrowserify = _interopRequireDefault(require("pseudoloc/index-browserify"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -27,2 +37,6 @@

_indexBrowserify.default.option.delimiter = '%';
_indexBrowserify.default.option.startDelimiter = '{';
_indexBrowserify.default.option.endDelimiter = '}';
var Translator =

@@ -58,2 +72,6 @@ /*#__PURE__*/

value: function createInstance(locale) {
if (this.options.pseudoLoc && this.options.phrases) {
this.options.phrases = this.psudoLocalizePhrases(this.options.phrases);
}
this.map[locale] = new _nodePolyglot.default(Object.assign(this.options, {

@@ -64,2 +82,13 @@ locale: locale

}, {
key: "psudoLocalizePhrases",
value: function psudoLocalizePhrases(phrases) {
return Object.entries(phrases).reduce(function (acc, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
return Object.assign(acc, _defineProperty({}, key, _indexBrowserify.default.str(value)));
}, {});
}
}, {
key: "getInstance",

@@ -88,2 +117,7 @@ value: function getInstance(locale) {

var p = this.getInstance(locale);
if (this.options.pseudoLoc) {
phrases = this.psudoLocalizePhrases(phrases);
}
p.extend(phrases);

@@ -119,2 +153,6 @@ }

value: function replace(phrases) {
if (this.options.pseudoLoc) {
phrases = this.psudoLocalizePhrases(phrases);
}
this.getInstance().replace(phrases);

@@ -121,0 +159,0 @@ }

7

package.json
{
"name": "@cloudflare/intl-core",
"description": "",
"version": "1.1.0",
"version": "1.1.1",
"types": "./src",

@@ -18,3 +18,4 @@ "main": "lib/index.js",

"lodash": "2.4.2",
"node-polyglot": "^2.3.0"
"node-polyglot": "^2.3.0",
"pseudoloc": "^1.1.0"
},

@@ -35,5 +36,5 @@ "stratus": {

"path": "es/index.js",
"limit": "36 KB"
"limit": "39 KB"
}
]
}

@@ -5,3 +5,12 @@ import Polyglot from 'node-polyglot';

import { mapValues } from 'lodash';
import pseudoloc from 'pseudoloc/index-browserify';
pseudoloc.option.delimiter = '%';
pseudoloc.option.startDelimiter = '{';
pseudoloc.option.endDelimiter = '}';
interface ITranslatorOptions extends Polyglot.PolyglotOptions {
pseudoLoc?: boolean;
}
class Translator {

@@ -12,5 +21,5 @@ map: {

currentLocale: ESupportedLocales = ESupportedLocales.en_US;
options?: Polyglot.PolyglotOptions;
options: ITranslatorOptions;
constructor(options?: Polyglot.PolyglotOptions) {
constructor(options?: ITranslatorOptions) {
this.map = {};

@@ -37,2 +46,6 @@ this.options = options || {};

private createInstance(locale: ESupportedLocales) {
if (this.options.pseudoLoc && this.options.phrases) {
this.options.phrases = this.psudoLocalizePhrases(this.options.phrases);
}
this.map[locale] = new Polyglot(

@@ -45,2 +58,10 @@ Object.assign(this.options, {

psudoLocalizePhrases(phrases: IPhrases) {
return Object.entries(phrases).reduce(
(acc, [key, value]) =>
Object.assign(acc, { [key]: pseudoloc.str(value) }),
{}
);
}
getInstance(locale?: ESupportedLocales) {

@@ -66,2 +87,7 @@ if (locale) {

const p = this.getInstance(locale);
if (this.options.pseudoLoc) {
phrases = this.psudoLocalizePhrases(phrases);
}
p.extend(phrases);

@@ -92,2 +118,6 @@ }

replace(phrases: IPhrases) {
if (this.options.pseudoLoc) {
phrases = this.psudoLocalizePhrases(phrases);
}
this.getInstance().replace(phrases);

@@ -94,0 +124,0 @@ }

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