@ohos-ports/utf8-bytes 0.0.1-beta.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 ADDED
@@ -0,0 +1,18 @@
1
+ This software is released under the MIT license:
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = function (str) {
2
+ return Array.from(Buffer.from(String(str), 'utf8'));
3
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@ohos-ports/utf8-bytes",
3
+ "version": "0.0.1-beta.1",
4
+ "description": "return an array of bytes from a unicode string",
5
+ "main": "index.js",
6
+ "dependencies": {},
7
+ "devDependencies": {
8
+ "tape": "~1.0.4"
9
+ },
10
+ "scripts": {
11
+ "test": "tape test/*.js"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/ohos-ports/ohos-ports.git",
16
+ "directory": "ports/utf8-bytes/0.0.1"
17
+ },
18
+ "homepage": "https://github.com/ohos-ports/ohos-ports/tree/main/ports/utf8-bytes/0.0.1",
19
+ "keywords": [
20
+ "utf8",
21
+ "utf-8",
22
+ "unicode",
23
+ "bytes",
24
+ "string",
25
+ "encoding"
26
+ ],
27
+ "author": {
28
+ "name": "James Halliday",
29
+ "email": "mail@substack.net",
30
+ "url": "http://substack.net"
31
+ },
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/ohos-ports/ohos-ports/issues"
35
+ },
36
+ "files": [
37
+ "index.js"
38
+ ]
39
+ }
@@ -0,0 +1,44 @@
1
+ # utf8-bytes
2
+
3
+ return an array of all the bytes in a unicode string
4
+
5
+ [![build status](https://secure.travis-ci.org/substack/utf8-bytes.png)](http://travis-ci.org/substack/utf8-bytes)
6
+
7
+ This module is like `Buffer(str).toJSON()`, but without using `Buffer`.
8
+
9
+ # example
10
+
11
+ ``` js
12
+ var bytes = require('utf8-bytes');
13
+ console.log(bytes('[☉,☼]'));
14
+ ```
15
+
16
+ output:
17
+
18
+ ```
19
+ $ node example/utf8-bytes.js
20
+ [ 91, 226, 152, 137, 44, 226, 152, 188, 93 ]
21
+ ```
22
+
23
+ # methods
24
+
25
+ ``` js
26
+ var bytes = require('utf8-bytes')
27
+ ```
28
+
29
+ ## bytes(str)
30
+
31
+ Return an array of integers from 0 through 255, inclusive, representing the
32
+ bytes in the unicode string `str`.
33
+
34
+ # install
35
+
36
+ With [npm](https://npmjs.org) do:
37
+
38
+ ```
39
+ npm install utf8-bytes
40
+ ```
41
+
42
+ # license
43
+
44
+ MIT