Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

intl-segmenter-polyfill-rs

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-segmenter-polyfill-rs - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

cjs/intl_segmenter_polyfill_rs_bg.wasm

30

package.json
{
"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"
}
}
}
}

39

README.md

@@ -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 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc