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

A polyfill for Intl.Segmenter

  • 0.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
767
decreased by-23.68%
Maintainers
1
Weekly downloads
 
Created
Source

Intl-Segmenter-Polyfill-rs

About

This project polyfills the Intl.Segmenter API for browsers that do not support it.

See the bugzilla issue here.

As firefox 122 will support the API, this project will be archived in a predictable future.

Packages are available at:

Usage

Install wasm-pack

cargo install wasm-pack

Install binaryen

Use your package manager to install binaryen.

Install icu4x-datagen

cargo install icu_datagen

Generate the data

bash icu-datagen.sh

Build

bash build.sh

Use it in your project

import * as IntlSegmeterPolyfill from "intl-segmenter-polyfill-rs";
// Browsers like firefox
if (Intl.Segmenter === undefined) {
    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!'
}

Use it directly in the browser

<!-- Modify your src according to your need -->
<script type="module" src="/node_modules/intl-segmenter-polyfill-rs-web/intl_segmenter_polyfill_rs.js"></script>

License

Licensed under either of

at your option.

FAQs

Package last updated on 10 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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