charcode-is-valid-xml-name-character 2.0.7 → 2.0.10
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/README.md
CHANGED
|
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 1.13.0
|
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
import { strict as assert } from "assert";
|
|
41
|
+
|
|
41
42
|
import {
|
|
42
43
|
isProduction4,
|
|
43
44
|
isProduction4a,
|
|
@@ -62,7 +63,7 @@ assert.equal(validSecondCharOnwards("?"), false);
|
|
|
62
63
|
|
|
63
64
|
## Documentation
|
|
64
65
|
|
|
65
|
-
Please [visit codsen.com](https://codsen.com/os/charcode-is-valid-xml-name-character/) for a full description of the API
|
|
66
|
+
Please [visit codsen.com](https://codsen.com/os/charcode-is-valid-xml-name-character/) for a full description of the API.
|
|
66
67
|
|
|
67
68
|
## Contributing
|
|
68
69
|
|
|
@@ -74,4 +75,6 @@ MIT License
|
|
|
74
75
|
|
|
75
76
|
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
76
77
|
|
|
78
|
+
|
|
77
79
|
<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">
|
|
80
|
+
|
|
@@ -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.10
|
|
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.10
|
|
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 i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols;var c=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var g=(n,e,r)=>e in n?i(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))b.call(e,r)&&g(n,r,e[r]);return n};var f=n=>i(n,"__esModule",{value:!0});var R=(n,e)=>{for(var r in e)i(n,r,{get:e[r],enumerable:!0})},h=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of p(e))!c.call(n,a)&&(r||a!=="default")&&i(n,a,{get:()=>e[a],enumerable:!(t=l(e,a))||t.enumerable});return n};var v=(n=>(e,r)=>n&&n.get(e)||(r=h(f({}),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 o(n,e,r){let t=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)?t.returnMatchedRangeInsteadOfTrue?e.find(a=>t.inclusiveRangeEnds?n>=a[0]&&n<=a[1]:n>a[0]&&n<a[1])||!1:e.some(a=>t.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]],s={inclusiveRangeEnds:!0,skipIncomingRangeSorting:!0};function A(n){return o(n.codePointAt(0),m,s)||o(n.codePointAt(0),y,s)}function P(n){return o(n.codePointAt(0),m,s)||o(n.codePointAt(0),x,s)}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.10
|
|
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.10",
|
|
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,37 @@
|
|
|
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
|
-
"
|
|
53
|
-
"republish": "npm publish || :",
|
|
54
|
-
"tap": "tap",
|
|
55
|
-
"pretest": "npm run build",
|
|
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
|
+
"dts": "rollup -c",
|
|
44
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
45
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
46
|
+
"letspublish": "yarn publish || :",
|
|
47
|
+
"lint": "eslint . --fix",
|
|
48
|
+
"perf": "node perf/check.js",
|
|
49
|
+
"prepare": "echo 'ready'",
|
|
50
|
+
"pretest": "yarn run lect && yarn run build",
|
|
51
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
52
|
+
"unit": "uvu test"
|
|
61
53
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
56
|
+
},
|
|
57
|
+
"c8": {
|
|
58
|
+
"check-coverage": true,
|
|
59
|
+
"exclude": [
|
|
60
|
+
"**/test/**/*.*"
|
|
68
61
|
],
|
|
69
|
-
"
|
|
62
|
+
"lines": 100
|
|
70
63
|
},
|
|
71
64
|
"lect": {
|
|
72
65
|
"licence": {
|
|
73
66
|
"extras": [
|
|
74
67
|
""
|
|
75
68
|
]
|
|
76
|
-
},
|
|
77
|
-
"req": "{ isProduction4, isProduction4a, validFirstChar, validSecondCharOnwards }",
|
|
78
|
-
"various": {
|
|
79
|
-
"devDependencies": []
|
|
80
69
|
}
|
|
81
70
|
},
|
|
82
71
|
"dependencies": {
|
|
83
|
-
"
|
|
84
|
-
"ranges-is-index-within": "^3.0.7"
|
|
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.10",
|
|
106
|
-
"@types/tap": "^15.0.5",
|
|
107
|
-
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
108
|
-
"@typescript-eslint/parser": "^5.5.0",
|
|
109
|
-
"core-js": "^3.19.2",
|
|
110
|
-
"cross-env": "^7.0.3",
|
|
111
|
-
"eslint": "^8.3.0",
|
|
112
|
-
"lect": "^0.18.7",
|
|
113
|
-
"rollup": "^2.60.1",
|
|
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.5",
|
|
120
|
-
"tslib": "^2.3.1",
|
|
121
|
-
"typescript": "^4.5.2"
|
|
122
|
-
},
|
|
123
|
-
"engines": {
|
|
124
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
72
|
+
"ranges-is-index-within": "^3.0.10"
|
|
125
73
|
}
|
|
126
74
|
}
|
package/types/index.d.ts
CHANGED
|
File without changes
|
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);"}}
|