New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

intl-segmenter-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-segmenter-polyfill - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

dist/index.d.ts

@@ -1,2 +0,2 @@

declare const createIntlSegmenterPolyfill: (wasm: Response | PromiseLike<Response>) => Promise<{
declare const createIntlSegmenterPolyfill: (wasm: ArrayBufferLike | PromiseLike<Response>) => Promise<{
new (locale: string, options: {

@@ -3,0 +3,0 @@ granularity: 'word' | 'grapheme';

@@ -53,22 +53,33 @@ "use strict";

};
var instantiateWasmModule = function (wasm, imports) {
if (typeof wasm.then === 'function') {
if (WebAssembly.instantiateStreaming != null) {
return WebAssembly.instantiateStreaming(wasm, imports);
}
return wasm
.then(function (response) { return response.arrayBuffer(); })
.then(function (buffer) { return WebAssembly.instantiate(buffer, imports); });
}
else {
return WebAssembly.instantiate(wasm, imports);
}
};
var createIntlSegmenterPolyfill = function (wasm) { return __awaiter(void 0, void 0, void 0, function () {
var breaks, instantiate, response, allocStr;
var breaks, response, allocStr;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
instantiate = WebAssembly.instantiateStreaming || WebAssembly.instantiate;
return [4 /*yield*/, instantiate(wasm, {
env: {
push: function (start, end, segmentType) {
breaks.push([start, end, segmentType]);
},
__sys_stat64: function () { }
case 0: return [4 /*yield*/, instantiateWasmModule(wasm, {
env: {
push: function (start, end, segmentType) {
breaks.push([start, end, segmentType]);
},
wasi_snapshot_preview1: {
proc_exit: function () { },
fd_close: function () { },
environ_sizes_get: function () { },
environ_get: function () { }
}
})];
__sys_stat64: function () { }
},
wasi_snapshot_preview1: {
proc_exit: function () { },
fd_close: function () { },
environ_sizes_get: function () { },
environ_get: function () { }
}
})];
case 1:

@@ -75,0 +86,0 @@ response = _a.sent();

{
"name": "intl-segmenter-polyfill",
"version": "0.2.4",
"version": "0.2.5",
"description": "This repo builds .wasm module using icu4c for breaking text into words, so that we can polyfill [Intl Segmenter Proposal](https://github.com/tc39/proposal-intl-segmenter) with full compatibility, even on browsers that do not expose v8BreakIterator api.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -17,11 +17,22 @@ const BREAK_TYPES = {

const instantiateWasmModule = (wasm, imports) => {
if (typeof wasm.then === 'function') {
if (WebAssembly.instantiateStreaming != null) {
return WebAssembly.instantiateStreaming(wasm, imports)
}
return wasm
.then((response) => response.arrayBuffer())
.then((buffer) => WebAssembly.instantiate(buffer, imports))
} else {
return WebAssembly.instantiate(wasm, imports)
}
}
const createIntlSegmenterPolyfill = async (
wasm: Response | PromiseLike<Response>,
wasm: ArrayBufferLike | PromiseLike<Response>
) => {
let breaks: [number, number, number][]
// node env does not support instantiateStreaming
const instantiate =
WebAssembly.instantiateStreaming || WebAssembly.instantiate
const response = await instantiate(wasm, {
const response = await instantiateWasmModule(wasm, {
env: {

@@ -28,0 +39,0 @@ push: (start: number, end: number, segmentType: number) => {

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