charcode-is-valid-xml-name-character 2.0.6 → 2.0.12
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/LICENSE +1 -1
- package/README.md +4 -5
- package/dist/charcode-is-valid-xml-name-character.esm.js +2 -60
- package/dist/charcode-is-valid-xml-name-character.umd.js +4 -4
- package/examples/_quickTake.js +1 -0
- package/package.json +25 -74
- package/types/index.d.ts +6 -1
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 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
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `1.13.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i charcode-is-valid-xml-name-character
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 1.13.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import {
|
|
42
41
|
isProduction4,
|
|
43
42
|
isProduction4a,
|
|
@@ -62,7 +61,7 @@ assert.equal(validSecondCharOnwards("?"), false);
|
|
|
62
61
|
|
|
63
62
|
## Documentation
|
|
64
63
|
|
|
65
|
-
Please [visit codsen.com](https://codsen.com/os/charcode-is-valid-xml-name-character/) for a full description of the API
|
|
64
|
+
Please [visit codsen.com](https://codsen.com/os/charcode-is-valid-xml-name-character/) for a full description of the API.
|
|
66
65
|
|
|
67
66
|
## Contributing
|
|
68
67
|
|
|
@@ -72,6 +71,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
72
71
|
|
|
73
72
|
MIT License
|
|
74
73
|
|
|
75
|
-
Copyright (c) 2010-
|
|
74
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
76
75
|
|
|
77
76
|
<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,68 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name charcode-is-valid-xml-name-character
|
|
3
3
|
* @fileoverview Does a given character belong to XML spec's "Production 4 OR 4a" type (is acceptable for XML element's name)
|
|
4
|
-
* @version 2.0.
|
|
4
|
+
* @version 2.0.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/charcode-is-valid-xml-name-character/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
const nameStartChar = [
|
|
13
|
-
[58, 58],
|
|
14
|
-
[65, 90],
|
|
15
|
-
[95, 95],
|
|
16
|
-
[192, 214],
|
|
17
|
-
[216, 246],
|
|
18
|
-
[248, 767],
|
|
19
|
-
[880, 893],
|
|
20
|
-
[895, 8191],
|
|
21
|
-
[8204, 8205],
|
|
22
|
-
[8304, 8591],
|
|
23
|
-
[11264, 12271],
|
|
24
|
-
[12289, 55295],
|
|
25
|
-
[63744, 64975],
|
|
26
|
-
[65008, 65533],
|
|
27
|
-
[65536, 983039],
|
|
28
|
-
];
|
|
29
|
-
const nameChar = [
|
|
30
|
-
[45, 45],
|
|
31
|
-
[46, 46],
|
|
32
|
-
[48, 57],
|
|
33
|
-
[58, 58],
|
|
34
|
-
[65, 90],
|
|
35
|
-
[95, 95],
|
|
36
|
-
[183, 183],
|
|
37
|
-
[192, 214],
|
|
38
|
-
[216, 246],
|
|
39
|
-
[248, 767],
|
|
40
|
-
[768, 879],
|
|
41
|
-
[880, 893],
|
|
42
|
-
[895, 8191],
|
|
43
|
-
[8204, 8205],
|
|
44
|
-
[8255, 8256],
|
|
45
|
-
[8304, 8591],
|
|
46
|
-
[11264, 12271],
|
|
47
|
-
[12289, 55295],
|
|
48
|
-
[63744, 64975],
|
|
49
|
-
[65008, 65533],
|
|
50
|
-
[65536, 983039],
|
|
51
|
-
];
|
|
52
|
-
const priorityNameChar = [
|
|
53
|
-
[97, 122],
|
|
54
|
-
];
|
|
55
|
-
const opts = {
|
|
56
|
-
inclusiveRangeEnds: true,
|
|
57
|
-
skipIncomingRangeSorting: true,
|
|
58
|
-
};
|
|
59
|
-
function isProduction4(char) {
|
|
60
|
-
return (isIndexWithin(char.codePointAt(0), priorityNameChar, opts) ||
|
|
61
|
-
isIndexWithin(char.codePointAt(0), nameStartChar, opts));
|
|
62
|
-
}
|
|
63
|
-
function isProduction4a(char) {
|
|
64
|
-
return (isIndexWithin(char.codePointAt(0), priorityNameChar, opts) ||
|
|
65
|
-
isIndexWithin(char.codePointAt(0), nameChar, opts));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { isProduction4, isProduction4a, isProduction4 as validFirstChar, isProduction4a as validSecondCharOnwards };
|
|
10
|
+
import{isIndexWithin as o}from"ranges-is-index-within";var a=[[58,58],[65,90],[95,95],[192,214],[216,246],[248,767],[880,893],[895,8191],[8204,8205],[8304,8591],[11264,12271],[12289,55295],[63744,64975],[65008,65533],[65536,983039]],s=[[45,45],[46,46],[48,57],[58,58],[65,90],[95,95],[183,183],[192,214],[216,246],[248,767],[768,879],[880,893],[895,8191],[8204,8205],[8255,8256],[8304,8591],[11264,12271],[12289,55295],[63744,64975],[65008,65533],[65536,983039]],t=[[97,122]],e={inclusiveRangeEnds:!0,skipIncomingRangeSorting:!0};function i(n){return o(n.codePointAt(0),t,e)||o(n.codePointAt(0),a,e)}function c(n){return o(n.codePointAt(0),t,e)||o(n.codePointAt(0),s,e)}export{i as isProduction4,c as isProduction4a,i as validFirstChar,c as validSecondCharOnwards};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name charcode-is-valid-xml-name-character
|
|
3
3
|
* @fileoverview Does a given character belong to XML spec's "Production 4 OR 4a" type (is acceptable for XML element's name)
|
|
4
|
-
* @version 2.0.
|
|
4
|
+
* @version 2.0.12
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/charcode-is-valid-xml-name-character/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var charcodeIsValidXmlNameCharacter=(()=>{var t=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols;var c=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;var g=(n,e,r)=>e in n?t(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,u=(n,e)=>{for(var r in e||(e={}))c.call(e,r)&&g(n,r,e[r]);if(d)for(var r of d(e))f.call(e,r)&&g(n,r,e[r]);return n};var p=n=>t(n,"__esModule",{value:!0});var R=(n,e)=>{for(var r in e)t(n,r,{get:e[r],enumerable:!0})},h=(n,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of b(e))!c.call(n,a)&&(r||a!=="default")&&t(n,a,{get:()=>e[a],enumerable:!(o=l(e,a))||o.enumerable});return n};var v=(n=>(e,r)=>n&&n.get(e)||(r=h(p({}),e,1),n&&n.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var w={};R(w,{isProduction4:()=>A,isProduction4a:()=>P,validFirstChar:()=>A,validSecondCharOnwards:()=>P});var I={inclusiveRangeEnds:!1,returnMatchedRangeInsteadOfTrue:!1};function s(n,e,r){let o=u(u({},I),r);if(!Number.isInteger(n))throw new Error(`ranges-is-index-within: [THROW_ID_01] the first input argument should be string index, a natural number (or zero). It was given as ${n} (type ${typeof n})`);return Array.isArray(e)?o.returnMatchedRangeInsteadOfTrue?e.find(a=>o.inclusiveRangeEnds?n>=a[0]&&n<=a[1]:n>a[0]&&n<a[1])||!1:e.some(a=>o.inclusiveRangeEnds?n>=a[0]&&n<=a[1]:n>a[0]&&n<a[1]):!1}var y=[[58,58],[65,90],[95,95],[192,214],[216,246],[248,767],[880,893],[895,8191],[8204,8205],[8304,8591],[11264,12271],[12289,55295],[63744,64975],[65008,65533],[65536,983039]],x=[[45,45],[46,46],[48,57],[58,58],[65,90],[95,95],[183,183],[192,214],[216,246],[248,767],[768,879],[880,893],[895,8191],[8204,8205],[8255,8256],[8304,8591],[11264,12271],[12289,55295],[63744,64975],[65008,65533],[65536,983039]],m=[[97,122]],i={inclusiveRangeEnds:!0,skipIncomingRangeSorting:!0};function A(n){return s(n.codePointAt(0),m,i)||s(n.codePointAt(0),y,i)}function P(n){return s(n.codePointAt(0),m,i)||s(n.codePointAt(0),x,i)}return v(w);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name ranges-is-index-within
|
|
13
13
|
* @fileoverview Checks if index is within any of the given string index ranges
|
|
14
|
-
* @version 3.0.
|
|
14
|
+
* @version 3.0.12
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/ranges-is-index-within/}
|
|
18
|
-
*/
|
|
18
|
+
*/
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "charcode-is-valid-xml-name-character",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Does a given character belong to XML spec's \"Production 4 OR 4a\" type (is acceptable for XML element's name)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"4",
|
|
@@ -38,89 +38,40 @@
|
|
|
38
38
|
},
|
|
39
39
|
"types": "types/index.d.ts",
|
|
40
40
|
"scripts": {
|
|
41
|
-
"build": "
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"prettier": "
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"test": "npm run test:ci && npm run perf",
|
|
57
|
-
"test:ci": "npm run unittest && npm run test:examples && npm run format",
|
|
58
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
59
|
-
"tsc": "tsc",
|
|
60
|
-
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
|
|
41
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
42
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
43
|
+
"devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
44
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
45
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
46
|
+
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
47
|
+
"letspublish": "yarn publish || :",
|
|
48
|
+
"lint": "eslint . --fix",
|
|
49
|
+
"perf": "node perf/check.js",
|
|
50
|
+
"prepare": "echo 'ready'",
|
|
51
|
+
"prettier": "prettier",
|
|
52
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
53
|
+
"pretest": "yarn run lect && yarn run build",
|
|
54
|
+
"test": "yarn run devtest",
|
|
55
|
+
"unit": "uvu test"
|
|
61
56
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
59
|
+
},
|
|
60
|
+
"c8": {
|
|
61
|
+
"check-coverage": true,
|
|
62
|
+
"exclude": [
|
|
63
|
+
"**/test/**/*.*"
|
|
68
64
|
],
|
|
69
|
-
"
|
|
65
|
+
"lines": 100
|
|
70
66
|
},
|
|
71
67
|
"lect": {
|
|
72
68
|
"licence": {
|
|
73
69
|
"extras": [
|
|
74
70
|
""
|
|
75
71
|
]
|
|
76
|
-
},
|
|
77
|
-
"req": "{ isProduction4, isProduction4a, validFirstChar, validSecondCharOnwards }",
|
|
78
|
-
"various": {
|
|
79
|
-
"devDependencies": []
|
|
80
72
|
}
|
|
81
73
|
},
|
|
82
74
|
"dependencies": {
|
|
83
|
-
"
|
|
84
|
-
"ranges-is-index-within": "^3.0.6"
|
|
85
|
-
},
|
|
86
|
-
"devDependencies": {
|
|
87
|
-
"@babel/cli": "^7.16.0",
|
|
88
|
-
"@babel/core": "^7.16.0",
|
|
89
|
-
"@babel/node": "^7.16.0",
|
|
90
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
91
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
92
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
93
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
94
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
95
|
-
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
96
|
-
"@babel/preset-env": "^7.16.4",
|
|
97
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
98
|
-
"@babel/register": "^7.16.0",
|
|
99
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
100
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
101
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
102
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
103
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
104
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
105
|
-
"@types/node": "^16.11.9",
|
|
106
|
-
"@types/tap": "^15.0.5",
|
|
107
|
-
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
108
|
-
"@typescript-eslint/parser": "^5.4.0",
|
|
109
|
-
"core-js": "^3.19.1",
|
|
110
|
-
"cross-env": "^7.0.3",
|
|
111
|
-
"eslint": "^8.3.0",
|
|
112
|
-
"lect": "^0.18.6",
|
|
113
|
-
"rollup": "^2.60.0",
|
|
114
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
115
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
116
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
117
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
118
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
119
|
-
"tap": "^15.1.2",
|
|
120
|
-
"tslib": "^2.3.1",
|
|
121
|
-
"typescript": "^4.5.2"
|
|
122
|
-
},
|
|
123
|
-
"engines": {
|
|
124
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
75
|
+
"ranges-is-index-within": "^3.0.12"
|
|
125
76
|
}
|
|
126
77
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
declare function isProduction4(char: string): boolean;
|
|
2
2
|
declare function isProduction4a(char: string): boolean;
|
|
3
3
|
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
isProduction4,
|
|
6
|
+
isProduction4a,
|
|
7
|
+
isProduction4 as validFirstChar,
|
|
8
|
+
isProduction4a as validSecondCharOnwards,
|
|
9
|
+
};
|
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport {\n isProduction4,\n isProduction4a,\n validFirstChar,\n validSecondCharOnwards,\n} from \"charcode-is-valid-xml-name-character\";\n\n// Spec: https://www.w3.org/TR/REC-xml/#NT-NameStartChar\n\nassert.equal(isProduction4(\"Z\"), true);\nassert.equal(isProduction4(\"?\"), false);\n\nassert.equal(isProduction4a(\"?\"), false);\nassert.equal(isProduction4a(\"-\"), true);\n\nassert.equal(validFirstChar(\"a\"), true);\nassert.equal(validFirstChar(\"1\"), false);\n\nassert.equal(validSecondCharOnwards(\"a\"), true);\nassert.equal(validSecondCharOnwards(\"?\"), false);"}}
|