intl-segmenter-polyfill-rs
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "intl-segmenter-polyfill-rs", | ||
"description": "A polyfill for Intl.Segmenter", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"license": "MIT OR Apache-2.0", | ||
@@ -11,7 +11,29 @@ "repository": { | ||
"files": [ | ||
"./*" | ||
"cjs", | ||
"esm", | ||
"LICENSE_APACHE", | ||
"LICENSE_MIT", | ||
"package.json", | ||
"README.md" | ||
], | ||
"main": "intl_segmenter_polyfill_rs.js", | ||
"module": "./esm/intl_segmenter_polyfill_rs.js", | ||
"homepage": "https://github.com/toeverything/intl-segmenter-polyfill-rs", | ||
"types": "intl_segmenter_polyfill_rs.d.ts" | ||
"types": "./cjs/intl_segmenter_polyfill_rs.d.ts", | ||
"sideEffects": [ | ||
"./esm/intl_segmenter_polyfill_rs.js", | ||
"./snippets/*" | ||
], | ||
"main": "./cjs/intl_segmenter_polyfill_rs.js", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"default": "./esm/intl_segmenter_polyfill_rs.js", | ||
"types": "./esm/intl_segmenter_polyfill_rs.d.ts" | ||
}, | ||
"require": { | ||
"default": "./cjs/intl_segmenter_polyfill_rs.js", | ||
"types": "./esm/intl_segmenter_polyfill_rs.d.ts" | ||
} | ||
} | ||
} | ||
} |
@@ -29,36 +29,25 @@ # Intl-Segmenter-Polyfill-rs | ||
### Build with `wasm-pack build` | ||
### Build | ||
``` | ||
wasm-pack build --target nodejs --release | ||
sh build.sh | ||
``` | ||
### Run the following commands to standardize the package.json | ||
``` | ||
sh before-publish.sh | ||
``` | ||
### Use it in your project | ||
```js | ||
import * as IntlSegmeterPolyfill from "intl-segmenter-polyfill-rs"; | ||
// Browsers like firefox | ||
import init, { Segmenter } from "intl-segmenter-polyfill-rs"; | ||
if (Intl.Segmenter === undefined) { | ||
// If you don't call init, the wasm won't be load. | ||
await init().then( | ||
() => { | ||
Intl.Segmenter = Segmenter; | ||
const segmenterFr = new Intl.Segmenter('fr', { granularity: 'sentence' }); | ||
const string1 = 'Hello World. Xin chào thế giới!'; | ||
const iterator1 = segmenterFr.segment(string1)[Symbol.iterator](); | ||
console.log(iterator1.next().value.segment); | ||
// Expected output: 'Hello World. ' | ||
console.log(iterator1.next().value.segment); | ||
// Expected output: 'Xin chào thế giới!' | ||
} | ||
); | ||
Intl.Segmenter = IntlSegmeterPolyfill.Segmenter; | ||
const segmenterFr = new Intl.Segmenter('fr', { granularity: 'sentence' }); | ||
const string1 = 'Hello World. Xin chào thế giới!'; | ||
const iterator1 = segmenterFr.segment(string1)[Symbol.iterator](); | ||
console.log(iterator1.next().value.segment); | ||
// Expected output: 'Hello World. ' | ||
console.log(iterator1.next().value.segment); | ||
// Expected output: 'Xin chào thế giới!' | ||
} | ||
@@ -65,0 +54,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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
4989445
16
978
2
63
3