isutf8 3.1.1 → 4.0.1
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 +12 -8
- package/{index.d.ts → dist/index.d.ts} +1 -2
- package/dist/index.esm.js +3 -3
- package/dist/index.js +2 -2
- package/package.json +27 -25
- package/CHANGELOG.md +0 -26
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Denis Seleznev, hcodes@yandex.ru
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
[](https://www.npmjs.org/package/isutf8)
|
|
2
2
|
[](https://www.npmjs.org/package/isutf8)
|
|
3
|
-
[](https://bundlephobia.com/result?p=isutf8)
|
|
4
|
+
[](https://packagephobia.com/result?p=isutf8)
|
|
4
5
|
|
|
5
6
|
isutf8
|
|
6
7
|
======
|
|
7
8
|
|
|
8
|
-
Quick check if a Node.js Buffer or Uint8Array is UTF-8.
|
|
9
|
+
Quick check if a Node.js Buffer or Uint8Array is valid UTF-8.
|
|
10
|
+
|
|
11
|
+
## Advantages
|
|
12
|
+
- Ultra-small package size
|
|
13
|
+
- No dependencies
|
|
14
|
+
- No pre-compilation
|
|
9
15
|
|
|
10
16
|
## Install
|
|
11
17
|
`npm install isutf8`
|
|
@@ -14,17 +20,15 @@ Quick check if a Node.js Buffer or Uint8Array is UTF-8.
|
|
|
14
20
|
|
|
15
21
|
### CommonJS
|
|
16
22
|
```js
|
|
17
|
-
'use strict';
|
|
18
|
-
|
|
19
23
|
const isUtf8 = require('isutf8');
|
|
20
24
|
|
|
21
25
|
const buf = Buffer.from([0xd0, 0x90]);
|
|
22
|
-
console.log(isUtf8(buf)); // =>
|
|
26
|
+
console.log(isUtf8(buf)); // => boolean
|
|
23
27
|
|
|
24
28
|
// or
|
|
25
29
|
|
|
26
30
|
const arr = new Uint8Array([0xd0, 0x90]);
|
|
27
|
-
console.log(isUtf8(arr)); // =>
|
|
31
|
+
console.log(isUtf8(arr)); // => boolean
|
|
28
32
|
|
|
29
33
|
```
|
|
30
34
|
|
|
@@ -33,12 +37,12 @@ console.log(isUtf8(arr)); // => true
|
|
|
33
37
|
import isUtf8 from 'isutf8';
|
|
34
38
|
|
|
35
39
|
const buf = Buffer.from([0xd0, 0x90]);
|
|
36
|
-
console.log(isUtf8(buf)); // =>
|
|
40
|
+
console.log(isUtf8(buf)); // => boolean
|
|
37
41
|
|
|
38
42
|
// or
|
|
39
43
|
|
|
40
44
|
const arr = new Uint8Array([0xd0, 0x90]);
|
|
41
|
-
console.log(isUtf8(arr)); // =>
|
|
45
|
+
console.log(isUtf8(arr)); // => boolean
|
|
42
46
|
```
|
|
43
47
|
|
|
44
48
|
## License
|
package/dist/index.esm.js
CHANGED
|
@@ -25,8 +25,8 @@ function isUtf8(buf) {
|
|
|
25
25
|
if (!buf) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
var i = 0;
|
|
29
|
+
var len = buf.length;
|
|
30
30
|
while (i < len) {
|
|
31
31
|
// UTF8-1 = %x00-7F
|
|
32
32
|
if (buf[i] <= 0x7F) {
|
|
@@ -76,4 +76,4 @@ function isUtf8(buf) {
|
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export default
|
|
79
|
+
export { isUtf8 as default };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isutf8",
|
|
3
|
-
"description": "Check if a Node.js Buffer or Uint8Array is
|
|
4
|
-
"version": "
|
|
3
|
+
"description": "Check if a Node.js Buffer or Uint8Array is UTF-8",
|
|
4
|
+
"version": "4.0.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Denis Seleznev",
|
|
7
7
|
"email": "hcodes@yandex.ru",
|
|
@@ -18,45 +18,47 @@
|
|
|
18
18
|
"keywords": [
|
|
19
19
|
"charset",
|
|
20
20
|
"utf-8",
|
|
21
|
+
"is utf",
|
|
22
|
+
"is utf-8",
|
|
23
|
+
"is utf8",
|
|
21
24
|
"utf8",
|
|
25
|
+
"unicode",
|
|
26
|
+
"is unicode",
|
|
22
27
|
"text",
|
|
28
|
+
"check",
|
|
29
|
+
"validate",
|
|
23
30
|
"encoding",
|
|
24
31
|
"Buffer",
|
|
25
32
|
"Uint8Array"
|
|
26
33
|
],
|
|
27
34
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
35
|
+
"node": ">= 12"
|
|
29
36
|
},
|
|
30
37
|
"devDependencies": {
|
|
31
|
-
"@rollup/plugin-typescript": "^
|
|
32
|
-
"@types/jest": "^
|
|
33
|
-
"@
|
|
34
|
-
"@typescript-eslint/
|
|
35
|
-
"
|
|
36
|
-
"eslint": "^
|
|
37
|
-
"jest": "^
|
|
38
|
-
"rollup": "^
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"typescript": "^4.0.3"
|
|
38
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
39
|
+
"@types/jest": "^29.5.12",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
41
|
+
"@typescript-eslint/parser": "^8.3.0",
|
|
42
|
+
"del-cli": "^5.1.0",
|
|
43
|
+
"eslint": "^8.3.0",
|
|
44
|
+
"jest": "^29.7.0",
|
|
45
|
+
"rollup": "^4.21.1",
|
|
46
|
+
"ts-jest": "^29.2.5",
|
|
47
|
+
"tslib": "^2.7.0",
|
|
48
|
+
"typescript": "^5.5.4"
|
|
43
49
|
},
|
|
44
50
|
"scripts": {
|
|
45
51
|
"test": "npm run eslint && npm run unit",
|
|
46
52
|
"eslint": "eslint --ext .ts",
|
|
47
|
-
"clean": "
|
|
53
|
+
"clean": "del-cli dist/*",
|
|
48
54
|
"unit": "jest --config ./jest.config.js",
|
|
49
|
-
"build": "npm run clean &&
|
|
50
|
-
"
|
|
51
|
-
"build:common": "rollup src/index.ts --config rollup.config.js --file dist/index.js --format commonjs --exports=auto"
|
|
55
|
+
"build": "npm run clean && rollup --config rollup.config.mjs",
|
|
56
|
+
"typecheck": "tsc --noEmit"
|
|
52
57
|
},
|
|
53
|
-
"
|
|
58
|
+
"typings": "dist/index.d.ts",
|
|
54
59
|
"files": [
|
|
55
60
|
"LICENSE",
|
|
56
61
|
"README.md",
|
|
57
|
-
"dist
|
|
58
|
-
|
|
59
|
-
"index.d.ts"
|
|
60
|
-
],
|
|
61
|
-
"dependencies": {}
|
|
62
|
+
"dist"
|
|
63
|
+
]
|
|
62
64
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Changelog
|
|
3
|
-
|
|
4
|
-
## v3.1.1
|
|
5
|
-
- Fixes for typings.
|
|
6
|
-
|
|
7
|
-
## v3.1.0
|
|
8
|
-
- Add support for ES modules.
|
|
9
|
-
|
|
10
|
-
## v3.0.0
|
|
11
|
-
- Add typings for TypeScript.
|
|
12
|
-
- Drop support for old Node.js < 10.
|
|
13
|
-
|
|
14
|
-
## v2.1.0
|
|
15
|
-
- Add support for `Uint8Array`.
|
|
16
|
-
- Updated dev deps in package.json.
|
|
17
|
-
|
|
18
|
-
## v2.0.4
|
|
19
|
-
- Updated dev deps in package.json.
|
|
20
|
-
|
|
21
|
-
## v2.0.3
|
|
22
|
-
- Updated dev deps in package.json.
|
|
23
|
-
|
|
24
|
-
## v2.0.2
|
|
25
|
-
- Added package-lock.json.
|
|
26
|
-
- Updated the example in README.md.
|