intl-locales-supported
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "intl-locales-supported", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Utility to help you polyfill the Node.js runtime when the Intl APIs are missing, or if the built-in Intl is missing locale data that you need.", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/yahoo/intl-locales-supported.git" | ||
"url": "https://github.com/formatjs/formatjs.git" | ||
}, | ||
@@ -21,5 +21,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/yahoo/intl-locales-supported/issues" | ||
"url": "https://github.com/formatjs/formatjs/issues" | ||
}, | ||
"homepage": "https://github.com/yahoo/intl-locales-supported", | ||
"homepage": "https://github.com/formatjs/formatjs", | ||
"scripts": { | ||
@@ -31,7 +31,3 @@ "test": "mocha test/unit/*.js" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "^0.3.1", | ||
"intl": "^0.1.4", | ||
"mocha": "^2.2.5" | ||
} | ||
"gitHead": "c1fada7a9fb25c4339ad938645146d0aed7daeb3" | ||
} |
@@ -7,4 +7,2 @@ intl-locales-supported | ||
[![npm Version][npm-badge]][npm] | ||
[![Build Status][travis-badge]][travis] | ||
[![Dependency Status][david-badge]][david] | ||
@@ -25,3 +23,3 @@ | ||
// `Intl` exists, but it doesn't have the data we need, so load the | ||
// polyfill and replace the constructors with need with the polyfill's. | ||
// polyfill and replace the constructors we need with the polyfill's. | ||
require('intl'); | ||
@@ -47,8 +45,4 @@ Intl.NumberFormat = IntlPolyfill.NumberFormat; | ||
[npm-badge]: https://img.shields.io/npm/v/intl-locales-supported.svg?style=flat-square | ||
[travis]: https://travis-ci.org/yahoo/intl-locales-supported | ||
[travis-badge]: https://img.shields.io/travis/yahoo/intl-locales-supported.svg?style=flat-square | ||
[david]: https://david-dm.org/yahoo/intl-locales-supported | ||
[david-badge]: https://img.shields.io/david/yahoo/intl-locales-supported.svg?style=flat-square | ||
[Intl]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl | ||
[FormatJS]: http://formatjs.io/ | ||
[LICENSE]: https://github.com/yahoo/intl-locales-supported/blob/master/LICENSE | ||
[LICENSE]: https://github.com/formatjs/formatjs/blob/master/LICENSE |
/* global beforeEach, afterEach, describe, it */ | ||
'use strict'; | ||
var Intl = global.Intl; | ||
var Intl = global.Intl; | ||
var IntlPolyfill = require('intl'); | ||
var expect = require('expect.js'); | ||
var expect = require('expect.js'); | ||
var areIntlLocalesSupported = require('../../'); | ||
describe('exports', function () { | ||
it('should have a default export function', function () { | ||
expect(areIntlLocalesSupported).to.be.a('function'); | ||
}); | ||
describe('exports', function() { | ||
it('should have a default export function', function() { | ||
expect(areIntlLocalesSupported).to.be.a('function'); | ||
}); | ||
}); | ||
describe('areIntlLocalesSupported()', function () { | ||
var globalIntl = null; | ||
describe('areIntlLocalesSupported()', function() { | ||
var globalIntl = null; | ||
function clearGlobalIntl() { | ||
if (Intl) { | ||
Object.getOwnPropertyNames(global.Intl).forEach(function (prop) { | ||
delete global.Intl[prop]; | ||
}); | ||
} else { | ||
global.Intl = {}; | ||
} | ||
function clearGlobalIntl() { | ||
if (Intl) { | ||
Object.getOwnPropertyNames(global.Intl).forEach(function(prop) { | ||
delete global.Intl[prop]; | ||
}); | ||
} else { | ||
global.Intl = {}; | ||
} | ||
} | ||
function copyProps(source, target) { | ||
return Object.getOwnPropertyNames(source).reduce(function (target, prop) { | ||
target[prop] = source[prop]; | ||
return target; | ||
}, target); | ||
} | ||
function copyProps(source, target) { | ||
return Object.getOwnPropertyNames(source).reduce(function(target, prop) { | ||
target[prop] = source[prop]; | ||
return target; | ||
}, target); | ||
} | ||
beforeEach(function () { | ||
globalIntl = copyProps(global.Intl, {}); | ||
beforeEach(function() { | ||
globalIntl = copyProps(global.Intl, {}); | ||
}); | ||
afterEach(function() { | ||
clearGlobalIntl(); | ||
copyProps(globalIntl, global.Intl); | ||
}); | ||
describe('missing Intl', function() { | ||
beforeEach(function() { | ||
clearGlobalIntl(); | ||
}); | ||
afterEach(function () { | ||
clearGlobalIntl(); | ||
copyProps(globalIntl, global.Intl); | ||
it('should return `false` for "en"', function() { | ||
expect(areIntlLocalesSupported('en')).to.be.false; | ||
}); | ||
}); | ||
describe('missing Intl', function () { | ||
beforeEach(function () { | ||
clearGlobalIntl(); | ||
}); | ||
describe('polyfill', function() { | ||
beforeEach(function() { | ||
clearGlobalIntl(); | ||
copyProps(IntlPolyfill, global.Intl); | ||
}); | ||
it('should return `false` for "en"', function () { | ||
expect(areIntlLocalesSupported('en')).to.be.false; | ||
}); | ||
it('should return `true` for "en"', function() { | ||
expect(areIntlLocalesSupported('en')).to.be.true; | ||
}); | ||
describe('polyfill', function () { | ||
beforeEach(function () { | ||
clearGlobalIntl(); | ||
copyProps(IntlPolyfill, global.Intl); | ||
}); | ||
it('should return `true` for "fr"', function() { | ||
expect(areIntlLocalesSupported('fr')).to.be.true; | ||
}); | ||
}); | ||
it('should return `true` for "en"', function () { | ||
expect(areIntlLocalesSupported('en')).to.be.true; | ||
}); | ||
if (Intl) { | ||
describe('built-in', function() { | ||
it('should return `true` for "en"', function() { | ||
expect(areIntlLocalesSupported('en')).to.be.true; | ||
}); | ||
it('should return `true` for "fr"', function () { | ||
expect(areIntlLocalesSupported('fr')).to.be.true; | ||
}); | ||
it('should return `false` for "fr"', function() { | ||
expect(areIntlLocalesSupported('fr')).to.be.false; | ||
}); | ||
}); | ||
if (Intl) { | ||
describe('built-in', function () { | ||
it('should return `true` for "en"', function () { | ||
expect(areIntlLocalesSupported('en')).to.be.true; | ||
}); | ||
it('should return `false` for "fr"', function () { | ||
expect(areIntlLocalesSupported('fr')).to.be.false; | ||
}); | ||
}); | ||
} | ||
} | ||
}); |
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
0
6760
5
46
1