i18n-iso-639-1
Advanced tools
Comparing version 1.1.3 to 2.0.0
{ | ||
"name": "i18n-iso-639-1", | ||
"version": "1.1.3", | ||
"version": "2.0.0", | ||
"description": "JavaScript utilities for ISO-639-1 codes", | ||
"homepage": "https://github.com/sanishmaharjan/i18n-iso-639-1.git#readme", | ||
"main": "./index.js", | ||
"main": "./build/i18n-iso-639-1.js", | ||
"scripts": { | ||
"build": "webpack", | ||
"test": "mocha" | ||
"build": "webpack --env dev && webpack --env build && npm run test", | ||
"dev": "webpack --progress --colors --watch --env dev", | ||
"test": "mocha --require babel-core/register --colors ./test/*.spec.js" | ||
}, | ||
@@ -30,14 +31,13 @@ "repository": { | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.0.3", | ||
"babel-loader": "^7.1.2", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-es2016": "^6.24.1", | ||
"babel-preset-stage-2": "^6.24.1", | ||
"clean-webpack-plugin": "^0.1.17", | ||
"babel-preset-env": "^1.6.1", | ||
"chai": "^4.1.2", | ||
"eslint": "^4.13.1", | ||
"eslint-loader": "^1.9.0", | ||
"mocha": "^4.0.1", | ||
"webpack": "^3.10.0" | ||
}, | ||
"dependencies": { | ||
"babel-preset-env": "^1.6.1" | ||
"webpack": "^3.10.0", | ||
"yargs": "^10.0.3" | ||
} | ||
} |
@@ -1,43 +0,50 @@ | ||
'use strict'; | ||
const isoCodes = require('./data'); | ||
const i18nIsoFunctions = { | ||
getLanguages : function getLanguages(codes) { | ||
return codes.map(code => ({ | ||
code, | ||
name: this.getName(code), | ||
nativeName: this.getNativeName(code), | ||
})); | ||
}, | ||
getAllNames : function getAllNames() { | ||
return Object.values(isoCodes).map(l => l.name); | ||
}, | ||
getName : function getName(code) { | ||
return this.validate(code) ? isoCodes[code].name : ''; | ||
}, | ||
getNativeName : function getNativeName(code) { | ||
return this.validate(code) ? isoCodes[code].nativeName : ''; | ||
}, | ||
getAllNativeNames : function getAllNativeNames() { | ||
return Object.values(isoCodes).map(l => l.nativeName); | ||
}, | ||
getAllCodes : function getAllCodes() { | ||
return Object.keys(isoCodes); | ||
}, | ||
getCode : function getCode(name) { | ||
const code = Object.keys(isoCodes).find(code => { | ||
const language = isoCodes[code]; | ||
return ( | ||
language.name.toLowerCase() === name.toLowerCase() || | ||
class IsoCodes { | ||
getLanguages(codes) { | ||
return codes.map(code => ({ | ||
code, | ||
name: this.getName(code), | ||
nativeName: this.getNativeName(code) | ||
})); | ||
} | ||
getAllNames() { | ||
return Object.values(isoCodes).map(l => l.name); | ||
} | ||
getName(code) { | ||
return this.validate(code) ? isoCodes[code].name : ''; | ||
} | ||
getAllNativeNames() { | ||
return Object.values(isoCodes).map(l => l.nativeName); | ||
} | ||
getNativeName(code) { | ||
return this.validate(code) ? isoCodes[code].nativeName : ''; | ||
} | ||
getAllCodes() { | ||
return Object.keys(isoCodes); | ||
} | ||
getCode(name) { | ||
const code = Object.keys(isoCodes).find(code => { | ||
const language = isoCodes[code]; | ||
return ( | ||
language.name.toLowerCase() === name.toLowerCase() || | ||
language.nativeName.toLowerCase() === name.toLowerCase() | ||
); | ||
}); | ||
return code || ''; | ||
}, | ||
validate : function validate(code) { | ||
return isoCodes[code] !== undefined; | ||
} | ||
}; | ||
); | ||
}); | ||
exports.i18nIsoFunctions = i18nIsoFunctions; | ||
return code || ''; | ||
} | ||
validate(code) { | ||
return isoCodes[code] !== undefined; | ||
} | ||
} | ||
export default new IsoCodes(); |
@@ -0,34 +1,49 @@ | ||
const webpack = require('webpack'); | ||
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin; | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const CleanWebpackPlugin = require('clean-webpack-plugin'); | ||
const env = require('yargs').argv.env; | ||
const pkg = require('./package.json'); | ||
let webpackConfig = { | ||
entry: { | ||
index: './src/index.js', | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, `./build`), | ||
filename: '[name].js' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: ['es2016', 'env', 'stage-2'], | ||
plugins: ['add-module-exports', 'transform-runtime'], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new webpack.NamedModulesPlugin(), | ||
new CleanWebpackPlugin(['./build']), | ||
], | ||
let libraryName = pkg.name; | ||
let plugins = [], outputFile; | ||
if (env === 'build') { | ||
plugins.push(new UglifyJsPlugin({minimize: true})); | ||
outputFile = libraryName + '.min.js'; | ||
} else { | ||
outputFile = libraryName + '.js'; | ||
} | ||
const config = { | ||
entry: __dirname + '/src/index.js', | ||
devtool: 'source-map', | ||
output: { | ||
path: __dirname + '/build', | ||
filename: outputFile, | ||
library: libraryName, | ||
libraryTarget: 'umd', | ||
umdNamedDefine: true | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /(\.jsx|\.js)$/, | ||
loader: 'babel-loader', | ||
exclude: /(node_modules|bower_components)/ | ||
}, | ||
{ | ||
test: /(\.jsx|\.js)$/, | ||
loader: 'eslint-loader', | ||
exclude: /node_modules/ | ||
} | ||
] | ||
}, | ||
resolve: { | ||
modules: [path.resolve('./node_modules'), path.resolve('./src')], | ||
extensions: ['.json', '.js'] | ||
}, | ||
plugins: plugins | ||
}; | ||
module.exports = webpackConfig; | ||
module.exports = config; |
71955
0
12
12
1055
- Removedbabel-preset-env@^1.6.1
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-helper-builder-binary-assignment-operator-visitor@6.24.1(transitive)
- Removedbabel-helper-call-delegate@6.24.1(transitive)
- Removedbabel-helper-define-map@6.26.0(transitive)
- Removedbabel-helper-explode-assignable-expression@6.24.1(transitive)
- Removedbabel-helper-function-name@6.24.1(transitive)
- Removedbabel-helper-get-function-arity@6.24.1(transitive)
- Removedbabel-helper-hoist-variables@6.24.1(transitive)
- Removedbabel-helper-optimise-call-expression@6.24.1(transitive)
- Removedbabel-helper-regex@6.26.0(transitive)
- Removedbabel-helper-remap-async-to-generator@6.24.1(transitive)
- Removedbabel-helper-replace-supers@6.24.1(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-check-es2015-constants@6.22.0(transitive)
- Removedbabel-plugin-syntax-async-functions@6.13.0(transitive)
- Removedbabel-plugin-syntax-exponentiation-operator@6.13.0(transitive)
- Removedbabel-plugin-syntax-trailing-function-commas@6.22.0(transitive)
- Removedbabel-plugin-transform-async-to-generator@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-arrow-functions@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-block-scoped-functions@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-block-scoping@6.26.0(transitive)
- Removedbabel-plugin-transform-es2015-classes@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-computed-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-destructuring@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-duplicate-keys@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-for-of@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-function-name@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-literals@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-modules-amd@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-modules-commonjs@6.26.2(transitive)
- Removedbabel-plugin-transform-es2015-modules-systemjs@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-modules-umd@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-object-super@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-parameters@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-shorthand-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-spread@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-sticky-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-template-literals@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-typeof-symbol@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-unicode-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-exponentiation-operator@6.24.1(transitive)
- Removedbabel-plugin-transform-regenerator@6.26.0(transitive)
- Removedbabel-plugin-transform-strict-mode@6.24.1(transitive)
- Removedbabel-preset-env@1.7.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedbrowserslist@3.2.8(transitive)
- Removedcaniuse-lite@1.0.30001695(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removedelectron-to-chromium@1.5.88(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesutils@2.0.3(transitive)
- Removedglobals@9.18.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjsesc@0.5.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedms@2.0.0(transitive)
- Removedprivate@0.1.8(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregenerator-transform@0.10.1(transitive)
- Removedregexpu-core@2.0.0(transitive)
- Removedregjsgen@0.2.0(transitive)
- Removedregjsparser@0.1.5(transitive)
- Removedsemver@5.7.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)