charcode-is-valid-xml-name-character 2.0.5 → 2.0.11
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 -21
- package/dist/charcode-is-valid-xml-name-character.umd.js +4 -4
- package/examples/_quickTake.js +1 -0
- package/package.json +24 -78
- 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,29 +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.11
|
|
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 = [[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]
|
|
13
|
-
];
|
|
14
|
-
const nameChar = [[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]
|
|
15
|
-
];
|
|
16
|
-
const priorityNameChar = [[97, 122]
|
|
17
|
-
];
|
|
18
|
-
const opts = {
|
|
19
|
-
inclusiveRangeEnds: true,
|
|
20
|
-
skipIncomingRangeSorting: true
|
|
21
|
-
};
|
|
22
|
-
function isProduction4(char) {
|
|
23
|
-
return isIndexWithin(char.codePointAt(0), priorityNameChar, opts) || isIndexWithin(char.codePointAt(0), nameStartChar, opts);
|
|
24
|
-
}
|
|
25
|
-
function isProduction4a(char) {
|
|
26
|
-
return isIndexWithin(char.codePointAt(0), priorityNameChar, opts) || isIndexWithin(char.codePointAt(0), nameChar, opts);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
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.11
|
|
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 b=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols;var c=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;var g=(n,e,a)=>e in n?i(n,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[e]=a,u=(n,e)=>{for(var a in e||(e={}))c.call(e,a)&&g(n,a,e[a]);if(d)for(var a of d(e))f.call(e,a)&&g(n,a,e[a]);return n};var p=n=>i(n,"__esModule",{value:!0});var R=(n,e)=>{for(var a in e)i(n,a,{get:e[a],enumerable:!0})},h=(n,e,a,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of b(e))!c.call(n,r)&&(a||r!=="default")&&i(n,r,{get:()=>e[r],enumerable:!(o=l(e,r))||o.enumerable});return n};var v=(n=>(e,a)=>n&&n.get(e)||(a=h(p({}),e,1),n&&n.set(e,a),a))(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,a){let o=u(u({},I),a);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(r=>o.inclusiveRangeEnds?n>=r[0]&&n<=r[1]:n>r[0]&&n<r[1])||!1:e.some(r=>o.inclusiveRangeEnds?n>=r[0]&&n<=r[1]:n>r[0]&&n<r[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]],t={inclusiveRangeEnds:!0,skipIncomingRangeSorting:!0};function A(n){return s(n.codePointAt(0),m,t)||s(n.codePointAt(0),y,t)}function P(n){return s(n.codePointAt(0),m,t)||s(n.codePointAt(0),x,t)}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.11
|
|
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.11",
|
|
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,93 +38,39 @@
|
|
|
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
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"tap": "tap",
|
|
56
|
-
"pretest": "npm run build",
|
|
57
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
58
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
59
|
-
"tsc": "tsc",
|
|
60
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
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 && yarn run prettier 'types/index.d.ts' --write",
|
|
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
|
+
"prettier": "prettier",
|
|
51
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
52
|
+
"pretest": "yarn run lect && yarn run build",
|
|
53
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
54
|
+
"unit": "uvu test"
|
|
61
55
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"--no-warnings",
|
|
70
|
-
"--experimental-loader",
|
|
71
|
-
"@istanbuljs/esm-loader-hook"
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
58
|
+
},
|
|
59
|
+
"c8": {
|
|
60
|
+
"check-coverage": true,
|
|
61
|
+
"exclude": [
|
|
62
|
+
"**/test/**/*.*"
|
|
72
63
|
],
|
|
73
|
-
"
|
|
64
|
+
"lines": 100
|
|
74
65
|
},
|
|
75
66
|
"lect": {
|
|
76
67
|
"licence": {
|
|
77
68
|
"extras": [
|
|
78
69
|
""
|
|
79
70
|
]
|
|
80
|
-
},
|
|
81
|
-
"req": "{ isProduction4, isProduction4a, validFirstChar, validSecondCharOnwards }",
|
|
82
|
-
"various": {
|
|
83
|
-
"devDependencies": []
|
|
84
71
|
}
|
|
85
72
|
},
|
|
86
73
|
"dependencies": {
|
|
87
|
-
"
|
|
88
|
-
"ranges-is-index-within": "^3.0.5"
|
|
89
|
-
},
|
|
90
|
-
"devDependencies": {
|
|
91
|
-
"@babel/cli": "^7.16.0",
|
|
92
|
-
"@babel/core": "^7.16.0",
|
|
93
|
-
"@babel/node": "^7.16.0",
|
|
94
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
95
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
96
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
97
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
98
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
99
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
100
|
-
"@babel/preset-env": "^7.16.0",
|
|
101
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
102
|
-
"@babel/register": "^7.16.0",
|
|
103
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
104
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
105
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
106
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
107
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
108
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
109
|
-
"@types/node": "^16.11.6",
|
|
110
|
-
"@types/tap": "^15.0.5",
|
|
111
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
112
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
113
|
-
"core-js": "^3.19.1",
|
|
114
|
-
"cross-env": "^7.0.3",
|
|
115
|
-
"eslint": "^8.2.0",
|
|
116
|
-
"lect": "^0.18.5",
|
|
117
|
-
"rollup": "^2.59.0",
|
|
118
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
119
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
120
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
121
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
122
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
123
|
-
"tap": "^15.0.10",
|
|
124
|
-
"tslib": "^2.3.1",
|
|
125
|
-
"typescript": "^4.4.4"
|
|
126
|
-
},
|
|
127
|
-
"engines": {
|
|
128
|
-
"node": ">=12"
|
|
74
|
+
"ranges-is-index-within": "^3.0.11"
|
|
129
75
|
}
|
|
130
76
|
}
|
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);"}}
|