UNPKG

@chartshq/datamodel

Version:

An environment with `node`, `rustup` and `wasm-pack` set up.

1 lines 13.5 kB
import*as wasm from"./datamodel_wasm_bg.wasm";var heap=new Array(32).fill(void 0);function getObject(t){return heap[t]}heap.push(void 0,null,!0,!1);var WASM_VECTOR_LEN=0,cachegetUint8Memory0=null;function getUint8Memory0(){return null!==cachegetUint8Memory0&&cachegetUint8Memory0.buffer===wasm.memory.buffer||(cachegetUint8Memory0=new Uint8Array(wasm.memory.buffer)),cachegetUint8Memory0}var lTextEncoder="undefined"==typeof TextEncoder?require("util").TextEncoder:TextEncoder,cachedTextEncoder=new lTextEncoder("utf-8"),encodeString="function"==typeof cachedTextEncoder.encodeInto?function(t,e){return cachedTextEncoder.encodeInto(t,e)}:function(t,e){var r=cachedTextEncoder.encode(t);return e.set(r),{read:t.length,written:r.length}};function passStringToWasm0(t,e,r){if(void 0===r){var a=cachedTextEncoder.encode(t),o=e(a.length);return getUint8Memory0().subarray(o,o+a.length).set(a),WASM_VECTOR_LEN=a.length,o}for(var n=t.length,i=e(n),p=getUint8Memory0(),_=0;_<n;_++){var c=t.charCodeAt(_);if(c>127)break;p[i+_]=c}if(_!==n){0!==_&&(t=t.slice(_)),i=r(i,n,n=_+3*t.length);var u=getUint8Memory0().subarray(i+_,i+n);_+=encodeString(t,u).written}return WASM_VECTOR_LEN=_,i}var cachegetInt32Memory0=null;function getInt32Memory0(){return null!==cachegetInt32Memory0&&cachegetInt32Memory0.buffer===wasm.memory.buffer||(cachegetInt32Memory0=new Int32Array(wasm.memory.buffer)),cachegetInt32Memory0}var heap_next=heap.length;function dropObject(t){t<36||(heap[t]=heap_next,heap_next=t)}function takeObject(t){var e=getObject(t);return dropObject(t),e}var lTextDecoder="undefined"==typeof TextDecoder?require("util").TextDecoder:TextDecoder,cachedTextDecoder=new lTextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function getStringFromWasm0(t,e){return cachedTextDecoder.decode(getUint8Memory0().subarray(t,t+e))}function _assertClass(t,e){if(!(t instanceof e))throw new Error("expected instance of "+e.name);return t.ptr}function addHeapObject(t){heap_next===heap.length&&heap.push(heap.length+1);var e=heap_next;return heap_next=heap[e],heap[e]=t,e}cachedTextDecoder.decode();var stack_pointer=32;function addBorrowedObject(t){if(1==stack_pointer)throw new Error("out of js stack");return heap[--stack_pointer]=t,stack_pointer}function getArrayI32FromWasm0(t,e){return getInt32Memory0().subarray(t/4,t/4+e)}var cachegetUint32Memory0=null;function getUint32Memory0(){return null!==cachegetUint32Memory0&&cachegetUint32Memory0.buffer===wasm.memory.buffer||(cachegetUint32Memory0=new Uint32Array(wasm.memory.buffer)),cachegetUint32Memory0}function getArrayU32FromWasm0(t,e){return getUint32Memory0().subarray(t/4,t/4+e)}var cachegetFloat64Memory0=null;function getFloat64Memory0(){return null!==cachegetFloat64Memory0&&cachegetFloat64Memory0.buffer===wasm.memory.buffer||(cachegetFloat64Memory0=new Float64Array(wasm.memory.buffer)),cachegetFloat64Memory0}function getArrayF64FromWasm0(t,e){return getFloat64Memory0().subarray(t/8,t/8+e)}export function main_js(){wasm.main_js()}export function stack_by(t,e,r,a,o){_assertClass(t,DataModel);var n=wasm.stack_by(t.ptr,e,r,a,o);return StackData.__wrap(n)}var CategoricalDomainMeta=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_categoricaldomainmeta_free(t)},Object.defineProperty(t.prototype,"data_ptr",{get:function(){return wasm.__wbg_get_categoricaldomainmeta_data_ptr(this.ptr)},set:function(t){wasm.__wbg_set_categoricaldomainmeta_data_ptr(this.ptr,t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"data_len",{get:function(){return wasm.__wbg_get_categoricaldomainmeta_data_len(this.ptr)>>>0},set:function(t){wasm.__wbg_set_categoricaldomainmeta_data_len(this.ptr,t)},enumerable:!1,configurable:!0}),t}();export{CategoricalDomainMeta};var CategoricalFieldWrapper=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_categoricalfieldwrapper_free(t)},t.prototype.get_name=function(){try{wasm.categoricalfieldwrapper_get_name(8,this.ptr);var t=getInt32Memory0()[2],e=getInt32Memory0()[3];return getStringFromWasm0(t,e)}finally{wasm.__wbindgen_free(t,e)}},t.prototype.get_data_indices=function(){return wasm.categoricalfieldwrapper_get_data_indices(this.ptr)},t.prototype.get_data_info=function(){return wasm.categoricalfieldwrapper_get_data_info(this.ptr)},t.prototype.get_rows_count=function(){return wasm.categoricalfieldwrapper_get_rows_count(this.ptr)>>>0},t.prototype.get_value_at_index=function(t){return wasm.categoricalfieldwrapper_get_value_at_index(this.ptr,t)},t.prototype.get_domain=function(){var t=wasm.categoricalfieldwrapper_get_domain(this.ptr);return CategoricalDomainMeta.__wrap(t)},t}();export{CategoricalFieldWrapper};var ContinuousFieldWrapper=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_continuousfieldwrapper_free(t)},t.prototype.get_name=function(){try{wasm.categoricalfieldwrapper_get_name(8,this.ptr);var t=getInt32Memory0()[2],e=getInt32Memory0()[3];return getStringFromWasm0(t,e)}finally{wasm.__wbindgen_free(t,e)}},t.prototype.get_data_ptr=function(){return wasm.continuousfieldwrapper_get_data_ptr(this.ptr)},t.prototype.get_data_indices=function(){return wasm.continuousfieldwrapper_get_data_indices(this.ptr)},t.prototype.get_data_info=function(){return wasm.continuousfieldwrapper_get_data_info(this.ptr)},t.prototype.get_rows_count=function(){return wasm.continuousfieldwrapper_get_rows_count(this.ptr)>>>0},t.prototype.get_value_at_index=function(t){return wasm.continuousfieldwrapper_get_value_at_index(this.ptr,t)},t.prototype.get_domain=function(){wasm.continuousfieldwrapper_get_domain(8,this.ptr);var t=getInt32Memory0()[2],e=getInt32Memory0()[3],r=getArrayF64FromWasm0(t,e).slice();return wasm.__wbindgen_free(t,8*e),r},t}();export{ContinuousFieldWrapper};var DataModel=function(){function t(e){_assertClass(e,DataModelMeta);var r=e.ptr;e.ptr=0;var a=wasm.datamodel_new(r);return t.__wrap(a)}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_datamodel_free(t)},t.prototype.clone=function(){var e=wasm.datamodel_clone(this.ptr);return t.__wrap(e)},t.prototype.add_field=function(t,e){return wasm.datamodel_add_field(this.ptr,addHeapObject(t),addHeapObject(e))>>>0},t.prototype.get_categorical_field=function(t){var e=wasm.datamodel_get_categorical_field(this.ptr,t);return CategoricalFieldWrapper.__wrap(e)},t.prototype.get_continuous_field=function(t){var e=wasm.datamodel_get_continuous_field(this.ptr,t);return ContinuousFieldWrapper.__wrap(e)},t.prototype.get_temporal_field=function(t){var e=wasm.datamodel_get_temporal_field(this.ptr,t);return TemporalFieldWrapper.__wrap(e)},t.prototype.get_id_field=function(t){var e=wasm.datamodel_get_id_field(this.ptr,t);return IdFieldWrapper.__wrap(e)},t.prototype.select=function(t,e){var r=wasm.datamodel_select(this.ptr,addHeapObject(t),e);return ProjectDataModel.__wrap(r)},t.prototype.sort=function(e){try{var r=wasm.datamodel_sort(this.ptr,addBorrowedObject(e));return t.__wrap(r)}finally{heap[stack_pointer++]=void 0}},t.prototype.project=function(t){try{var e=wasm.datamodel_project(this.ptr,addBorrowedObject(t));return ProjectDataModel.__wrap(e)}finally{heap[stack_pointer++]=void 0}},t.prototype.group_by=function(e,r){var a=wasm.datamodel_group_by(this.ptr,addHeapObject(e),addHeapObject(r));return t.__wrap(a)},t.prototype.split_by_row=function(t){var e=wasm.datamodel_split_by_row(this.ptr,addHeapObject(t));return SplitDataModel.__wrap(e)},t.prototype.dispose=function(t){wasm.datamodel_dispose(this.ptr,addHeapObject(t))},t.prototype.row_count=function(){return wasm.datamodel_row_count(this.ptr)>>>0},t.prototype.column_count=function(){return wasm.datamodel_column_count(this.ptr)>>>0},t.prototype.get_eligible_rows=function(){wasm.datamodel_get_eligible_rows(8,this.ptr);var t=getInt32Memory0()[2],e=getInt32Memory0()[3],r=getArrayI32FromWasm0(t,e).slice();return wasm.__wbindgen_free(t,4*e),r},t.prototype.get_partial_column_count=function(){return wasm.datamodel_get_partial_column_count(this.ptr)>>>0},t.prototype.get_partial_row_count=function(){return wasm.datamodel_get_partial_row_count(this.ptr)>>>0},t.prototype.get_matching_ids=function(e){_assertClass(e,t),wasm.datamodel_get_matching_ids(8,this.ptr,e.ptr);var r=getInt32Memory0()[2],a=getInt32Memory0()[3],o=getArrayU32FromWasm0(r,a).slice();return wasm.__wbindgen_free(r,4*a),o},t}();export{DataModel};var DataModelMeta=function(){function t(e,r){var a=wasm.datamodelmeta_new(e,r);return t.__wrap(a)}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_datamodelmeta_free(t)},Object.defineProperty(t.prototype,"rows",{get:function(){return wasm.__wbg_get_datamodelmeta_rows(this.ptr)>>>0},set:function(t){wasm.__wbg_set_datamodelmeta_rows(this.ptr,t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return wasm.__wbg_get_datamodelmeta_columns(this.ptr)>>>0},set:function(t){wasm.__wbg_set_datamodelmeta_columns(this.ptr,t)},enumerable:!1,configurable:!0}),t}();export{DataModelMeta};var IdFieldWrapper=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_idfieldwrapper_free(t)},t.prototype.get_name=function(){try{wasm.categoricalfieldwrapper_get_name(8,this.ptr);var t=getInt32Memory0()[2],e=getInt32Memory0()[3];return getStringFromWasm0(t,e)}finally{wasm.__wbindgen_free(t,e)}},t.prototype.get_data_ptr=function(){return wasm.idfieldwrapper_get_data_ptr(this.ptr)},t.prototype.get_data_indices=function(){return wasm.idfieldwrapper_get_data_indices(this.ptr)},t.prototype.get_data_info=function(){return wasm.idfieldwrapper_get_data_info(this.ptr)},t.prototype.get_rows_count=function(){return wasm.idfieldwrapper_get_rows_count(this.ptr)>>>0},t.prototype.get_value_at_index=function(t){return wasm.idfieldwrapper_get_value_at_index(this.ptr,t)},t}();export{IdFieldWrapper};var ProjectDataModel=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_projectdatamodel_free(t)},t.prototype.get_filtered_dm=function(){var t=wasm.projectdatamodel_get_filtered_dm(this.ptr);return 0===t?void 0:DataModel.__wrap(t)},t.prototype.get_unfiltered_dm=function(){var t=wasm.projectdatamodel_get_unfiltered_dm(this.ptr);return 0===t?void 0:DataModel.__wrap(t)},t}();export{ProjectDataModel};var SplitDataModel=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_splitdatamodel_free(t)},t.prototype.get_dm=function(){var t=wasm.splitdatamodel_get_dm(this.ptr);return DataModel.__wrap(t)},t.prototype.get_count=function(){return wasm.datamodel_column_count(this.ptr)>>>0},t}();export{SplitDataModel};var StackData=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_stackdata_free(t)},t.prototype.get_y_0=function(){return wasm.stackdata_get_y_0(this.ptr)},t.prototype.get_y_1=function(){return wasm.stackdata_get_y_1(this.ptr)},t.prototype.get_id=function(){return wasm.stackdata_get_id(this.ptr)},t.prototype.free_data=function(){wasm.stackdata_free_data(this.ptr)},t}();export{StackData};var TemporalFieldWrapper=function(){function t(){}return t.__wrap=function(e){var r=Object.create(t.prototype);return r.ptr=e,r},t.prototype.free=function(){var t=this.ptr;this.ptr=0,wasm.__wbg_temporalfieldwrapper_free(t)},t.prototype.get_name=function(){try{wasm.categoricalfieldwrapper_get_name(8,this.ptr);var t=getInt32Memory0()[2],e=getInt32Memory0()[3];return getStringFromWasm0(t,e)}finally{wasm.__wbindgen_free(t,e)}},t.prototype.get_data_ptr=function(){return wasm.temporalfieldwrapper_get_data_ptr(this.ptr)},t.prototype.get_data_indices=function(){return wasm.temporalfieldwrapper_get_data_indices(this.ptr)},t.prototype.get_data_info=function(){return wasm.categoricalfieldwrapper_get_data_info(this.ptr)},t.prototype.get_rows_count=function(){return wasm.categoricalfieldwrapper_get_rows_count(this.ptr)>>>0},t.prototype.get_value_at_index=function(t){return wasm.temporalfieldwrapper_get_value_at_index(this.ptr,t)},t.prototype.min_consecutive_diff=function(){return wasm.temporalfieldwrapper_min_consecutive_diff(this.ptr)},t.prototype.get_domain=function(){wasm.temporalfieldwrapper_get_domain(8,this.ptr);var t=getInt32Memory0()[2],e=getInt32Memory0()[3],r=getArrayF64FromWasm0(t,e).slice();return wasm.__wbindgen_free(t,8*e),r},t}();export{TemporalFieldWrapper};export var __wbindgen_json_serialize=function(t,e){var r=getObject(e),a=passStringToWasm0(JSON.stringify(void 0===r?null:r),wasm.__wbindgen_malloc,wasm.__wbindgen_realloc),o=WASM_VECTOR_LEN;getInt32Memory0()[t/4+1]=o,getInt32Memory0()[t/4+0]=a};export var __wbindgen_object_drop_ref=function(t){takeObject(t)};export var __wbindgen_throw=function(t,e){throw new Error(getStringFromWasm0(t,e))};wasm.__wbindgen_start();