@one-ini/wasm
Advanced tools
Comparing version 0.1.1 to 0.1.2
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* @param {string} contents | ||
* @returns {any} | ||
*/ | ||
* @param {string} contents | ||
* @returns {any} | ||
*/ | ||
export function parse_to_json(contents: string): any; | ||
/** | ||
* @returns {string} | ||
*/ | ||
* @returns {string} | ||
*/ | ||
export function version(): string; | ||
/** | ||
* @param {Uint8Array} contents | ||
* @returns {Uint32Array} | ||
*/ | ||
* @param {Uint8Array} contents | ||
* @returns {Uint32Array} | ||
*/ | ||
export function parse_to_uint32array(contents: Uint8Array): Uint32Array; | ||
/** | ||
*/ | ||
export enum TokenTypes { | ||
Key, | ||
Value, | ||
Section, | ||
CommentIndicator, | ||
CommentValue, | ||
Key = 0, | ||
Value = 1, | ||
Section = 2, | ||
CommentIndicator = 3, | ||
CommentValue = 4, | ||
} |
214
one_ini.js
@@ -0,1 +1,2 @@ | ||
let imports = {}; | ||
@@ -6,22 +7,2 @@ imports['__wbindgen_placeholder__'] = module.exports; | ||
const heap = new Array(32).fill(undefined); | ||
heap.push(undefined, null, true, false); | ||
function getObject(idx) { return heap[idx]; } | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
@@ -31,24 +12,16 @@ | ||
let cachedUint8Memory0 = new Uint8Array(); | ||
let cachedUint8ArrayMemory0 = null; | ||
function getUint8Memory0() { | ||
if (cachedUint8Memory0.byteLength === 0) { | ||
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
function getUint8ArrayMemory0() { | ||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { | ||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachedUint8Memory0; | ||
return cachedUint8ArrayMemory0; | ||
} | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
ptr = ptr >>> 0; | ||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function debugString(val) { | ||
@@ -140,4 +113,4 @@ // primitive types | ||
const buf = cachedTextEncoder.encode(arg); | ||
const ptr = malloc(buf.length); | ||
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); | ||
const ptr = malloc(buf.length, 1) >>> 0; | ||
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); | ||
WASM_VECTOR_LEN = buf.length; | ||
@@ -148,5 +121,5 @@ return ptr; | ||
let len = arg.length; | ||
let ptr = malloc(len); | ||
let ptr = malloc(len, 1) >>> 0; | ||
const mem = getUint8Memory0(); | ||
const mem = getUint8ArrayMemory0(); | ||
@@ -165,7 +138,8 @@ let offset = 0; | ||
} | ||
ptr = realloc(ptr, len, len = offset + arg.length * 3); | ||
const view = getUint8Memory0().subarray(ptr + offset, ptr + len); | ||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; | ||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); | ||
const ret = encodeString(arg, view); | ||
offset += ret.written; | ||
ptr = realloc(ptr, len, offset, 1) >>> 0; | ||
} | ||
@@ -177,14 +151,14 @@ | ||
let cachedInt32Memory0 = new Int32Array(); | ||
let cachedDataViewMemory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
function getDataViewMemory0() { | ||
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { | ||
cachedDataViewMemory0 = new DataView(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
return cachedDataViewMemory0; | ||
} | ||
/** | ||
* @param {string} contents | ||
* @returns {any} | ||
*/ | ||
* @param {string} contents | ||
* @returns {any} | ||
*/ | ||
module.exports.parse_to_json = function(contents) { | ||
@@ -194,18 +168,18 @@ const ptr0 = passStringToWasm0(contents, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const ret = wasm.parse_to_json(ptr0, len0); | ||
return takeObject(ret); | ||
return ret; | ||
}; | ||
/** | ||
* @returns {string} | ||
*/ | ||
* @returns {string} | ||
*/ | ||
module.exports.version = function() { | ||
let deferred1_0; | ||
let deferred1_1; | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.version(retptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
return getStringFromWasm0(r0, r1); | ||
const ret = wasm.version(); | ||
deferred1_0 = ret[0]; | ||
deferred1_1 = ret[1]; | ||
return getStringFromWasm0(ret[0], ret[1]); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(r0, r1); | ||
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); | ||
} | ||
@@ -215,4 +189,4 @@ }; | ||
function passArray8ToWasm0(arg, malloc) { | ||
const ptr = malloc(arg.length * 1); | ||
getUint8Memory0().set(arg, ptr / 1); | ||
const ptr = malloc(arg.length * 1, 1) >>> 0; | ||
getUint8ArrayMemory0().set(arg, ptr / 1); | ||
WASM_VECTOR_LEN = arg.length; | ||
@@ -222,39 +196,43 @@ return ptr; | ||
let cachedUint32Memory0 = new Uint32Array(); | ||
function takeFromExternrefTable0(idx) { | ||
const value = wasm.__wbindgen_export_2.get(idx); | ||
wasm.__externref_table_dealloc(idx); | ||
return value; | ||
} | ||
function getUint32Memory0() { | ||
if (cachedUint32Memory0.byteLength === 0) { | ||
cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer); | ||
let cachedUint32ArrayMemory0 = null; | ||
function getUint32ArrayMemory0() { | ||
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) { | ||
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer); | ||
} | ||
return cachedUint32Memory0; | ||
return cachedUint32ArrayMemory0; | ||
} | ||
function getArrayU32FromWasm0(ptr, len) { | ||
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len); | ||
ptr = ptr >>> 0; | ||
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); | ||
} | ||
/** | ||
* @param {Uint8Array} contents | ||
* @returns {Uint32Array} | ||
*/ | ||
* @param {Uint8Array} contents | ||
* @returns {Uint32Array} | ||
*/ | ||
module.exports.parse_to_uint32array = function(contents) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(contents, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.parse_to_uint32array(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
var r3 = getInt32Memory0()[retptr / 4 + 3]; | ||
if (r3) { | ||
throw takeObject(r2); | ||
} | ||
var v1 = getArrayU32FromWasm0(r0, r1).slice(); | ||
wasm.__wbindgen_free(r0, r1 * 4); | ||
return v1; | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
const ptr0 = passArray8ToWasm0(contents, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.parse_to_uint32array(ptr0, len0); | ||
if (ret[3]) { | ||
throw takeFromExternrefTable0(ret[2]); | ||
} | ||
var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice(); | ||
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); | ||
return v2; | ||
}; | ||
function addToExternrefTable0(obj) { | ||
const idx = wasm.__externref_table_alloc(); | ||
wasm.__wbindgen_export_2.set(idx, obj); | ||
return idx; | ||
} | ||
function handleError(f, args) { | ||
@@ -264,16 +242,12 @@ try { | ||
} catch (e) { | ||
wasm.__wbindgen_exn_store(addHeapObject(e)); | ||
const idx = addToExternrefTable0(e); | ||
wasm.__wbindgen_exn_store(idx); | ||
} | ||
} | ||
/** | ||
*/ | ||
module.exports.TokenTypes = Object.freeze({ Key:0,"0":"Key",Value:1,"1":"Value",Section:2,"2":"Section",CommentIndicator:3,"3":"CommentIndicator",CommentValue:4,"4":"CommentValue", }); | ||
module.exports.__wbindgen_object_drop_ref = function(arg0) { | ||
takeObject(arg0); | ||
}; | ||
module.exports.__wbindgen_error_new = function(arg0, arg1) { | ||
const ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
return ret; | ||
}; | ||
@@ -283,39 +257,34 @@ | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
return ret; | ||
}; | ||
module.exports.__wbindgen_object_clone_ref = function(arg0) { | ||
const ret = getObject(arg0); | ||
return addHeapObject(ret); | ||
module.exports.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) { | ||
arg0[arg1] = arg2; | ||
}; | ||
module.exports.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) { | ||
getObject(arg0)[takeObject(arg1)] = takeObject(arg2); | ||
}; | ||
module.exports.__wbg_new_1d9a920c6bfc44a8 = function() { | ||
module.exports.__wbg_new_034f913e7636e987 = function() { | ||
const ret = new Array(); | ||
return addHeapObject(ret); | ||
return ret; | ||
}; | ||
module.exports.__wbg_new_0b9bfdd97583284e = function() { | ||
module.exports.__wbg_new_e69b5f66fda8f13c = function() { | ||
const ret = new Object(); | ||
return addHeapObject(ret); | ||
return ret; | ||
}; | ||
module.exports.__wbg_set_a68214f35c417fa9 = function(arg0, arg1, arg2) { | ||
getObject(arg0)[arg1 >>> 0] = takeObject(arg2); | ||
module.exports.__wbg_set_425e70f7c64ac962 = function(arg0, arg1, arg2) { | ||
arg0[arg1 >>> 0] = arg2; | ||
}; | ||
module.exports.__wbg_fromCodePoint_3a5b15ba4d213634 = function() { return handleError(function (arg0) { | ||
module.exports.__wbg_fromCodePoint_a9176a674cd93db9 = function() { return handleError(function (arg0) { | ||
const ret = String.fromCodePoint(arg0 >>> 0); | ||
return addHeapObject(ret); | ||
return ret; | ||
}, arguments) }; | ||
module.exports.__wbindgen_debug_string = function(arg0, arg1) { | ||
const ret = debugString(getObject(arg1)); | ||
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
const ret = debugString(arg1); | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); | ||
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); | ||
}; | ||
@@ -327,2 +296,13 @@ | ||
module.exports.__wbindgen_init_externref_table = function() { | ||
const table = wasm.__wbindgen_export_2; | ||
const offset = table.grow(4); | ||
table.set(0, undefined); | ||
table.set(offset + 0, undefined); | ||
table.set(offset + 1, null); | ||
table.set(offset + 2, true); | ||
table.set(offset + 3, false); | ||
; | ||
}; | ||
const path = require('path').join(__dirname, 'one_ini_bg.wasm'); | ||
@@ -336,1 +316,3 @@ const bytes = require('fs').readFileSync(path); | ||
wasm.__wbindgen_start(); | ||
@@ -9,3 +9,3 @@ { | ||
"description": "Parse EditorConfig-INI file contents into AST", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -29,2 +29,2 @@ "repository": { | ||
] | ||
} | ||
} |
@@ -15,3 +15,3 @@ # One INI | ||
The work on this project started with the search for an universal parser for the [EditorConfig INI file format specification](https://editorconfig-specification.readthedocs.io/en/latest/#id3). | ||
The work on this project started with the search for an universal parser for the [EditorConfig INI file format specification](https://spec.editorconfig.org/#file-format). | ||
@@ -32,6 +32,6 @@ ## WASM | ||
You can call the genereted JS wrapper with either: | ||
You can call the generated JS wrapper with either: | ||
```js | ||
import { parse_to_json } from './pkg/editorconfig_ini.js' | ||
import { parse_to_json } from './pkg/one_ini.js' | ||
@@ -38,0 +38,0 @@ const results = parse_to_json(` |
Sorry, the diff of this file is not supported yet
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
106527
284