encode-utf8
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -1,2 +0,2 @@ | ||
declare function encodeUtf8 (input: string): ArrayBuffer | ||
export = encodeUtf8 | ||
/** @returns an ArrayBuffer with the `input` string represented as UTF8 encoded data */ | ||
export default function encodeUtf8 (input: string): ArrayBuffer |
14
index.js
@@ -1,12 +0,10 @@ | ||
'use strict' | ||
export default function encodeUtf8 (input) { | ||
const result = [] | ||
const size = input.length | ||
module.exports = function encodeUtf8 (input) { | ||
var result = [] | ||
var size = input.length | ||
for (let index = 0; index < size; index++) { | ||
let point = input.charCodeAt(index) | ||
for (var index = 0; index < size; index++) { | ||
var point = input.charCodeAt(index) | ||
if (point >= 0xD800 && point <= 0xDBFF && size > index + 1) { | ||
var second = input.charCodeAt(index + 1) | ||
const second = input.charCodeAt(index + 1) | ||
@@ -13,0 +11,0 @@ if (second >= 0xDC00 && second <= 0xDFFF) { |
{ | ||
"name": "encode-utf8", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
"repository": "LinusU/encode-utf8", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"scripts": { | ||
"test": "standard && mocha" | ||
"test": "standard && mocha && ts-readme-generator --check" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^6.2.2", | ||
"standard": "^14.3.1" | ||
"mocha": "^9.0.2", | ||
"standard": "^16.0.3", | ||
"ts-readme-generator": "^0.5.1" | ||
}, | ||
"engines": { | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
} | ||
} |
@@ -8,3 +8,3 @@ # Encode UTF8 | ||
```js | ||
npm install --save encode-uf8 | ||
npm install --save encode-utf8 | ||
``` | ||
@@ -15,3 +15,3 @@ | ||
```js | ||
const encodeUtf8 = require('encode-utf8') | ||
import encodeUtf8 from 'encode-utf8' | ||
@@ -27,4 +27,5 @@ console.log(encodeUtf8('Hello, World!')) | ||
### `encodeUtf8(input: string): ArrayBuffer` | ||
### `encodeUtf8(input)` | ||
Returns an ArrayBuffer with the string represented as UTF8 encoded data. | ||
- `input` (`string`, required) | ||
- returns `ArrayBuffer` - an ArrayBuffer with the `input` string represented as UTF8 encoded data |
/* eslint-env mocha */ | ||
'use strict' | ||
import assert from 'node:assert' | ||
import encodeUtf8 from './index.js' | ||
const assert = require('assert') | ||
const encodeUtf8 = require('./') | ||
const testCases = [ | ||
@@ -9,0 +7,0 @@ '゚・✿ヾ╲(。◕‿◕。)╱✿・゚', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4789
6
29
Yes
3
111