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

onigasm

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onigasm - npm Package Compare versions

Comparing version 1.3.1 to 2.0.0

src/index.ts

76

lib/onigasmH.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const OnigasmModuleFactory = require('./onigasm.js' /** when TS is compiled to JS, this will mean `lib/onigasm.js` (emitted by `emcc`) */);
function initModule(bytes) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
OnigasmModuleFactory({
instantiateWasm(imports, successCallback) {
WebAssembly.instantiate(bytes, imports)
.then((output) => {
successCallback(output.instance);
})
.catch((e) => {
throw e;
});
return {};
}
})
.then(moduleH => {
exports.onigasmH = moduleH;
resolve();
});
async function initModule(bytes) {
return new Promise((resolve, reject) => {
OnigasmModuleFactory({
instantiateWasm(imports, successCallback) {
WebAssembly.instantiate(bytes, imports)
.then((output) => {
successCallback(output.instance);
})
.catch((e) => {
throw e;
});
return {};
}
})
.then(moduleH => {
exports.onigasmH = moduleH;
resolve();
});

@@ -39,21 +29,19 @@ });

*/
function loadWASM(data) {
return __awaiter(this, void 0, void 0, function* () {
if (isInitialized) {
throw new Error(`Onigasm#init has been called and was succesful, subsequent calls are not allowed once initialized`);
}
if (typeof data === 'string') {
const arrayBuffer = yield (yield fetch(data)).arrayBuffer();
yield initModule(arrayBuffer);
}
else if (data instanceof ArrayBuffer) {
yield initModule(data);
}
else {
throw new TypeError(`Expected a string (URL of .wasm file) or ArrayBuffer (.wasm file itself) as first parameter`);
}
isInitialized = true;
});
async function loadWASM(data) {
if (isInitialized) {
throw new Error(`Onigasm#init has been called and was succesful, subsequent calls are not allowed once initialized`);
}
if (typeof data === 'string') {
const arrayBuffer = await (await fetch(data)).arrayBuffer();
await initModule(arrayBuffer);
}
else if (data instanceof ArrayBuffer) {
await initModule(data);
}
else {
throw new TypeError(`Expected a string (URL of .wasm file) or ArrayBuffer (.wasm file itself) as first parameter`);
}
isInitialized = true;
}
exports.loadWASM = loadWASM;
//# sourceMappingURL=onigasmH.js.map
{
"name": "onigasm",
"version": "1.3.1",
"version": "2.0.0",
"description": "WebAssembly port of Oniguruma regex library",

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

{
"compilerOptions": {
"target": "es6",
"target": "esnext",
"module": "commonjs",

@@ -5,0 +5,0 @@ "sourceMap": true,

Sorry, the diff of this file is not supported yet

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