is-language-code 1.0.10 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 2.0.0 (2020-11-28)
7
+
8
+ ### Features
9
+
10
+ - init ([00776db](https://git.sr.ht/~royston/codsen/commits/00776db3a81ecd9a683580fd459a756c462338f5))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ - init
15
+
6
16
  ## 1.0.0 (2020-01-05)
7
17
 
8
18
  ### Features
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2015-2020 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2020 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -2,7 +2,27 @@
2
2
 
3
3
  > Is given string a language code (as per IANA)
4
4
 
5
- <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center">
5
+ <div class="package-badges">
6
+ <a href="https://www.npmjs.com/package/is-language-code" rel="nofollow noreferrer noopener">
7
+ <img src="https://img.shields.io/badge/-npm-blue?style=flat-square" alt="page on npm">
8
+ </a>
9
+ <a href="https://codsen.com/os/is-language-code" rel="nofollow noreferrer noopener">
10
+ <img src="https://img.shields.io/badge/-codsen-blue?style=flat-square" alt="page on codsen.com">
11
+ </a>
12
+ <a href="https://git.sr.ht/~royston/codsen/tree/master/packages/is-language-code" rel="nofollow noreferrer noopener">
13
+ <img src="https://img.shields.io/badge/-sourcehut-blue?style=flat-square" alt="page on sourcehut">
14
+ </a>
15
+ <a href="https://npmcharts.com/compare/is-language-code?interval=30" rel="nofollow noreferrer noopener" target="_blank">
16
+ <img src="https://img.shields.io/npm/dm/is-language-code.svg?style=flat-square" alt="Downloads per month">
17
+ </a>
18
+ <a href="https://prettier.io" rel="nofollow noreferrer noopener" target="_blank">
19
+ <img src="https://img.shields.io/badge/code_style-prettier-brightgreen.svg?style=flat-square" alt="Code style: prettier">
20
+ </a>
21
+ <img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg?style=flat-square" alt="MIT License">
22
+ <a href="https://liberamanifesto.com" rel="nofollow noreferrer noopener" target="_blank">
23
+ <img src="https://img.shields.io/badge/libera-manifesto-lightgrey.svg?style=flat-square" alt="libera manifesto">
24
+ </a>
25
+ </div>
6
26
 
7
27
  ## Install
8
28
 
@@ -10,18 +30,31 @@
10
30
  npm i is-language-code
11
31
  ```
12
32
 
13
- <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center">
33
+ ## Quick Take
14
34
 
15
- ## Documentation
35
+ ```js
36
+ import { strict as assert } from "assert";
37
+ import isLangCode from "dist/is-language-code.esm";
38
+
39
+ assert.deepEqual(isLangCode("de-419-DE"), {
40
+ res: false,
41
+ message: 'Two region subtags, "419" and "de".',
42
+ });
16
43
 
17
- Please [visit our documentation](https://codsen.com/os/is-language-code/) for a full description of the API and examples.
44
+ assert.deepEqual(isLangCode("sr-Latn"), {
45
+ res: true,
46
+ message: null,
47
+ });
48
+ ```
49
+
50
+ ## Documentation
18
51
 
19
- <img src="https://codsen.com/images/png-codsen-star.png" width="42" alt="star" align="center">
52
+ Please [visit codsen.com](https://codsen.com/os/is-language-code/) for a full description of the API and examples.
20
53
 
21
54
  ## Licence
22
55
 
23
56
  MIT License
24
57
 
25
- Copyright (c) 2015-2020 Roy Revelt and other contributors
58
+ Copyright (c) 2010-2020 Roy Revelt and other contributors
26
59
 
27
- <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
60
+ <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * is-language-code
3
3
  * Is given string a language code (as per IANA)
4
- * Version: 1.0.10
4
+ * Version: 2.0.0
5
5
  * Author: Roy Revelt, Codsen Ltd
6
6
  * License: MIT
7
7
  * Homepage: https://codsen.com/os/is-language-code/
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * is-language-code
3
3
  * Is given string a language code (as per IANA)
4
- * Version: 1.0.10
4
+ * Version: 2.0.0
5
5
  * Author: Roy Revelt, Codsen Ltd
6
6
  * License: MIT
7
7
  * Homepage: https://codsen.com/os/is-language-code/
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * is-language-code
3
3
  * Is given string a language code (as per IANA)
4
- * Version: 1.0.10
4
+ * Version: 2.0.0
5
5
  * Author: Roy Revelt, Codsen Ltd
6
6
  * License: MIT
7
7
  * Homepage: https://codsen.com/os/is-language-code/
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * is-language-code
3
3
  * Is given string a language code (as per IANA)
4
- * Version: 1.0.10
4
+ * Version: 2.0.0
5
5
  * Author: Roy Revelt, Codsen Ltd
6
6
  * License: MIT
7
7
  * Homepage: https://codsen.com/os/is-language-code/
@@ -0,0 +1,16 @@
1
+ /* eslint import/extensions:0, no-unused-vars:0 */
2
+
3
+ // Quick Take
4
+
5
+ import { strict as assert } from "assert";
6
+ import isLangCode from "../dist/is-language-code.esm";
7
+
8
+ assert.deepEqual(isLangCode("de-419-DE"), {
9
+ res: false,
10
+ message: 'Two region subtags, "419" and "de".',
11
+ });
12
+
13
+ assert.deepEqual(isLangCode("sr-Latn"), {
14
+ res: true,
15
+ message: null,
16
+ });
@@ -0,0 +1 @@
1
+ {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport isLangCode from \"dist/is-language-code.esm\";\n\nassert.deepEqual(isLangCode(\"de-419-DE\"), &#x7B;\n res: false,\n message: 'Two region subtags, \"419\" and \"de\".',\n&#x7D;);\n\nassert.deepEqual(isLangCode(\"sr-Latn\"), &#x7B;\n res: true,\n message: null,\n&#x7D;);"},"various.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport isLangCode from \"dist/is-language-code.esm\";\n\nassert.equal(isLangCode(\"de\").res, true);\n// => true because it's a German language code\n\nassert.equal(isLangCode(\"fr\").res, true);\n// => true because it's a French language code\n\nassert.equal(isLangCode(\"ja\").res, true);\n// => true because it's a Japanese language code\n\nassert.equal(isLangCode(\"zzz\").res, false);\n// => false - unrecognised. npm package \"ietf-language-tag-regex\" would fail this\n\nassert.equal(isLangCode(\"1\").res, false);\n// => false - not recognised language code\n\nassert.equal(isLangCode(\"x-klingon\").res, true);\n// => true - private use\n\nassert.equal(isLangCode(\"x-whatever\").res, true);\n// => true - private use\n\nassert.equal(isLangCode(\"zh-Hant\").res, true);\n// => true - Chinese written using the Traditional Chinese script\n\nassert.equal(isLangCode(\"zh-cmn-Hans-CN\").res, true);\n// => true - Chinese, Mandarin, Simplified script, as used in China\n\nassert.equal(isLangCode(\"zh-Hans-CN\").res, true);\n// => true - Chinese written using the Simplified script as used in mainland China\n\nassert.equal(isLangCode(\"sr-Latn-RS\").res, true);\n// => true - Serbian written using the Latin script as used in Serbia\n\nassert.equal(isLangCode(\"sl-rozaj\").res, true);\n// => true - Resian dialect of Slovenian\n\nassert.equal(isLangCode(\"sl-nedis\").res, true);\n// => true - Nadiza dialect of Slovenian\n\nassert.equal(isLangCode(\"de-CH-1901\").res, true);\n// => true - German as used in Switzerland using the 1901 variant [orthography]\n\nassert.equal(isLangCode(\"sl-IT-nedis\").res, true);\n// => true - Slovenian as used in Italy, Nadiza dialect\n\nassert.equal(isLangCode(\"hy-Latn-IT-arevela\").res, true);\n// => true - Eastern Armenian written in Latin script, as used in Italy\n\nassert.equal(isLangCode(\"en-US\").res, true);\n// => true - English as used in the United States\n\nassert.equal(isLangCode(\"de-CH-x-phonebk\").res, true);\n// => true - private use subtag (x-)\n\nassert.equal(isLangCode(\"az-Arab-x-AZE-derbend\").res, true);\n// => true - private use subtag\n\nassert.equal(isLangCode(\"x-whatever\").res, true);\n// => true - private use subtag using singleton x-\n\nassert.equal(isLangCode(\"qaa-Qaaa-QM-x-southern\").res, true);\n// => true\n\nassert.equal(isLangCode(\"de-Qaaa\").res, true);\n// => true - private use script subtag (Qaaa)\n\nassert.equal(isLangCode(\"sr-Latn-QM\").res, true);\n// => true - Serbian, Latin script, private region QM\n\nassert.equal(isLangCode(\"en-US-u-islamcal\").res, true);\n// => true - tag with extension\n\nassert.equal(isLangCode(\"zh-CN-a-myext-x-private\").res, true);\n// => true - tag with extension\n\nassert.equal(isLangCode(\"en-a-myext-b-another\").res, true);\n// => true - tag with extension\n\nassert.equal(isLangCode(\"de-419-DE\").res, false);\n// => false - two region tags\n\nassert.equal(isLangCode(\"a-DE\").res, false);\n// => false - use of a single-character subtag in primary position\n\nassert.equal(isLangCode(\"ar-a-aaa-b-bbb-a-ccc\").res, false);\n// => false - two extensions with same single-letter prefix"}}
@@ -0,0 +1,93 @@
1
+ /* eslint import/extensions:0, no-unused-vars:0 */
2
+
3
+ // Quick Take
4
+
5
+ import { strict as assert } from "assert";
6
+ import isLangCode from "../dist/is-language-code.esm";
7
+
8
+ assert.equal(isLangCode("de").res, true);
9
+ // => true because it's a German language code
10
+
11
+ assert.equal(isLangCode("fr").res, true);
12
+ // => true because it's a French language code
13
+
14
+ assert.equal(isLangCode("ja").res, true);
15
+ // => true because it's a Japanese language code
16
+
17
+ assert.equal(isLangCode("zzz").res, false);
18
+ // => false - unrecognised. npm package "ietf-language-tag-regex" would fail this
19
+
20
+ assert.equal(isLangCode("1").res, false);
21
+ // => false - not recognised language code
22
+
23
+ assert.equal(isLangCode("x-klingon").res, true);
24
+ // => true - private use
25
+
26
+ assert.equal(isLangCode("x-whatever").res, true);
27
+ // => true - private use
28
+
29
+ assert.equal(isLangCode("zh-Hant").res, true);
30
+ // => true - Chinese written using the Traditional Chinese script
31
+
32
+ assert.equal(isLangCode("zh-cmn-Hans-CN").res, true);
33
+ // => true - Chinese, Mandarin, Simplified script, as used in China
34
+
35
+ assert.equal(isLangCode("zh-Hans-CN").res, true);
36
+ // => true - Chinese written using the Simplified script as used in mainland China
37
+
38
+ assert.equal(isLangCode("sr-Latn-RS").res, true);
39
+ // => true - Serbian written using the Latin script as used in Serbia
40
+
41
+ assert.equal(isLangCode("sl-rozaj").res, true);
42
+ // => true - Resian dialect of Slovenian
43
+
44
+ assert.equal(isLangCode("sl-nedis").res, true);
45
+ // => true - Nadiza dialect of Slovenian
46
+
47
+ assert.equal(isLangCode("de-CH-1901").res, true);
48
+ // => true - German as used in Switzerland using the 1901 variant [orthography]
49
+
50
+ assert.equal(isLangCode("sl-IT-nedis").res, true);
51
+ // => true - Slovenian as used in Italy, Nadiza dialect
52
+
53
+ assert.equal(isLangCode("hy-Latn-IT-arevela").res, true);
54
+ // => true - Eastern Armenian written in Latin script, as used in Italy
55
+
56
+ assert.equal(isLangCode("en-US").res, true);
57
+ // => true - English as used in the United States
58
+
59
+ assert.equal(isLangCode("de-CH-x-phonebk").res, true);
60
+ // => true - private use subtag (x-)
61
+
62
+ assert.equal(isLangCode("az-Arab-x-AZE-derbend").res, true);
63
+ // => true - private use subtag
64
+
65
+ assert.equal(isLangCode("x-whatever").res, true);
66
+ // => true - private use subtag using singleton x-
67
+
68
+ assert.equal(isLangCode("qaa-Qaaa-QM-x-southern").res, true);
69
+ // => true
70
+
71
+ assert.equal(isLangCode("de-Qaaa").res, true);
72
+ // => true - private use script subtag (Qaaa)
73
+
74
+ assert.equal(isLangCode("sr-Latn-QM").res, true);
75
+ // => true - Serbian, Latin script, private region QM
76
+
77
+ assert.equal(isLangCode("en-US-u-islamcal").res, true);
78
+ // => true - tag with extension
79
+
80
+ assert.equal(isLangCode("zh-CN-a-myext-x-private").res, true);
81
+ // => true - tag with extension
82
+
83
+ assert.equal(isLangCode("en-a-myext-b-another").res, true);
84
+ // => true - tag with extension
85
+
86
+ assert.equal(isLangCode("de-419-DE").res, false);
87
+ // => false - two region tags
88
+
89
+ assert.equal(isLangCode("a-DE").res, false);
90
+ // => false - use of a single-character subtag in primary position
91
+
92
+ assert.equal(isLangCode("ar-a-aaa-b-bbb-a-ccc").res, false);
93
+ // => false - two extensions with same single-letter prefix
package/package.json CHANGED
@@ -1,15 +1,7 @@
1
1
  {
2
2
  "name": "is-language-code",
3
- "version": "1.0.10",
3
+ "version": "2.0.0",
4
4
  "description": "Is given string a language code (as per IANA)",
5
- "license": "MIT",
6
- "repository": "https://gitlab.com/codsen/codsen/",
7
- "homepage": "https://codsen.com/os/is-language-code/",
8
- "author": {
9
- "email": "roy@codsen.com",
10
- "name": "Roy Revelt",
11
- "url": "codsen.com"
12
- },
13
5
  "keywords": [
14
6
  "check",
15
7
  "code",
@@ -28,6 +20,14 @@
28
20
  "valid",
29
21
  "validate"
30
22
  ],
23
+ "homepage": "https://codsen.com/os/is-language-code/",
24
+ "repository": "https://git.sr.ht/~royston/codsen",
25
+ "license": "MIT",
26
+ "author": {
27
+ "name": "Roy Revelt",
28
+ "email": "roy@codsen.com",
29
+ "url": "https://codsen.com"
30
+ },
31
31
  "main": "dist/is-language-code.cjs.js",
32
32
  "module": "dist/is-language-code.esm.js",
33
33
  "browser": "dist/is-language-code.umd.js",
@@ -46,7 +46,8 @@
46
46
  "republish": "npm publish || :",
47
47
  "tap": "tap",
48
48
  "pretest": "npm run build",
49
- "test": "npm run lint && npm run unittest && npm run clean_cov && npm run format",
49
+ "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
50
+ "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
50
51
  "tsd": "tsd",
51
52
  "unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md && npm run clean_cov && npm run perf",
52
53
  "version": "npm run build && git add ."
@@ -56,6 +57,17 @@
56
57
  "pre-commit": "npm run format && npm test"
57
58
  }
58
59
  },
60
+ "tap": {
61
+ "coverage-report": [
62
+ "json-summary",
63
+ "text"
64
+ ],
65
+ "nyc-arg": [
66
+ "--exclude=**/*.cjs.js",
67
+ "--exclude=**/*.umd.js"
68
+ ],
69
+ "timeout": 0
70
+ },
59
71
  "lect": {
60
72
  "defaultExported": true,
61
73
  "files": {
@@ -85,45 +97,33 @@
85
97
  "goodFolders": []
86
98
  },
87
99
  "req": "isLangCode",
88
- "typeSriptDefinitions": false,
89
100
  "various": {
90
101
  "devDependencies": [
91
102
  "@rollup/plugin-json"
92
103
  ]
93
104
  }
94
105
  },
95
- "tap": {
96
- "coverage-report": [
97
- "json-summary",
98
- "text"
99
- ],
100
- "nyc-arg": [
101
- "--exclude=**/*.cjs.js",
102
- "--exclude=**/*.umd.js"
103
- ],
104
- "timeout": 0
105
- },
106
106
  "devDependencies": {
107
- "@babel/core": "^7.11.6",
108
- "@babel/plugin-proposal-class-properties": "^7.10.4",
109
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
110
- "@babel/plugin-proposal-object-rest-spread": "^7.11.0",
111
- "@babel/plugin-proposal-optional-chaining": "^7.11.0",
112
- "@babel/preset-env": "^7.11.5",
113
- "@rollup/plugin-babel": "^5.2.0",
114
- "@rollup/plugin-commonjs": "^15.0.0",
107
+ "@babel/core": "^7.12.7",
108
+ "@babel/plugin-proposal-class-properties": "^7.12.1",
109
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
110
+ "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
111
+ "@babel/plugin-proposal-optional-chaining": "^7.12.7",
112
+ "@babel/preset-env": "^7.12.7",
113
+ "@rollup/plugin-babel": "^5.2.1",
114
+ "@rollup/plugin-commonjs": "^16.0.0",
115
115
  "@rollup/plugin-json": "^4.1.0",
116
- "@rollup/plugin-node-resolve": "^9.0.0",
116
+ "@rollup/plugin-node-resolve": "^10.0.0",
117
117
  "@rollup/plugin-strip": "^2.0.0",
118
118
  "benchmark": "^2.1.4",
119
- "eslint": "^7.8.1",
120
- "lect": "^0.13.11",
121
- "rollup": "^2.26.10",
119
+ "eslint": "^7.14.0",
120
+ "lect": "^0.15.0",
121
+ "rollup": "^2.33.3",
122
122
  "rollup-plugin-ascii": "^0.0.3",
123
123
  "rollup-plugin-banner": "^0.2.1",
124
- "rollup-plugin-cleanup": "^3.1.1",
124
+ "rollup-plugin-cleanup": "^3.2.1",
125
125
  "rollup-plugin-terser": "^7.0.2",
126
- "tap": "^14.10.8",
126
+ "tap": "^14.11.0",
127
127
  "tsd": "^0.13.1"
128
128
  }
129
129
  }