diff --git a/index.js b/index.js index 3fc7524..5f4d0de 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,6 @@ 'use strict'; -var forEach = require('array.prototype.foreach'); var entries = require('object.entries'); var warning = require('warning'); var has = require('hasown'); @@ -118,13 +117,14 @@ var defaultPluralRules = { function langToTypeMap(mapping) { var ret = {}; - forEach(entries(mapping), function (entry) { - var type = entry[0]; - var langs = entry[1]; - forEach(langs, function (lang) { - ret[lang] = type; - }); - }); + var mappingEntries = entries(mapping); + for (var i = 0; i < mappingEntries.length; i += 1) { + var type = mappingEntries[i][0]; + var langs = mappingEntries[i][1]; + for (var j = 0; j < langs.length; j += 1) { + ret[langs[j]] = type; + } + } return ret; } @@ -325,16 +325,17 @@ Polyglot.prototype.locale = function (newLocale) { // // This feature is used internally to support nested phrase objects. Polyglot.prototype.extend = function (morePhrases, prefix) { - forEach(entries(morePhrases || {}), function (entry) { - var key = entry[0]; - var phrase = entry[1]; + var phraseEntries = entries(morePhrases || {}); + for (var i = 0; i < phraseEntries.length; i += 1) { + var key = phraseEntries[i][0]; + var phrase = phraseEntries[i][1]; var prefixedKey = prefix ? prefix + '.' + key : key; if (typeof phrase === 'object') { this.extend(phrase, prefixedKey); } else { this.phrases[prefixedKey] = phrase; } - }, this); + } }; // ### polyglot.unset(phrases) @@ -352,16 +353,17 @@ Polyglot.prototype.unset = function (morePhrases, prefix) { if (typeof morePhrases === 'string') { delete this.phrases[morePhrases]; } else { - forEach(entries(morePhrases || {}), function (entry) { - var key = entry[0]; - var phrase = entry[1]; + var phraseEntries = entries(morePhrases || {}); + for (var i = 0; i < phraseEntries.length; i += 1) { + var key = phraseEntries[i][0]; + var phrase = phraseEntries[i][1]; var prefixedKey = prefix ? prefix + '.' + key : key; if (typeof phrase === 'object') { this.unset(phrase, prefixedKey); } else { delete this.phrases[prefixedKey]; } - }, this); + } } }; diff --git a/package.json b/package.json index 695a8d1..2d98feb 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,12 @@ ], "author": "Spike Brehm ", "dependencies": { - "array.prototype.foreach": "^1.0.7", "hasown": "^2.0.2", "object.entries": "^1.1.8", "warning": "^4.0.3" }, "devDependencies": { + "array.prototype.foreach": "^1.0.7", "aud": "^2.0.4", "chai": "^3.5.0", "docco": "^0.7.0",