Registry / data / cwise-compiler

cwise-compiler

JSON →
library1.1.3jsnpmunverified

cwise-compiler is the internal compiler component of the cwise library for ndarray-optimized operations. Version 1.1.3 is the current stable release. It provides a lower-level API to compile cwise procedures directly, bypassing the parser (cwise-parser) and esprima. This package is intended for advanced users who need to skip the standard cwise interface. It compiles a procedure object containing parsed pre, body, and post functions into optimized JavaScript. The main differentiator is its role as a core piece of the cwise ecosystem, offering a minimal, direct compilation path for ndarray operations.

npm install cwise-compiler
INSTALL
IMPORT
SIG · CWISE-COMPILER
C
cwise-compiler
datajavascriptv1.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
import compiler from 'cwise-compiler'
const { compiler } = require('cwise-compiler')
Default export is the compiler function; named import is incorrect.
compiler function
const compiler = require('cwise-compiler')
const compiler = require('cwise-compiler').default
CommonJS require gives the function directly; no .default needed.
TypeScript import
import compiler from 'cwise-compiler'
import * as compiler from 'cwise-compiler'
The module has no named exports; namespace import is incorrect.

Demonstrates compiling a simple procedure that adds one to each element of an ndarray.

const compiler = require('cwise-compiler'); const procedure = { args: ['array', 'array'], pre: { body: 'function pre() { var a = 0; }', args: [], thisVars: ['a'], localVars: [] }, body: { body: 'function body(a, b) { a = b + 1; }', args: ['a', 'b'], thisVars: [], localVars: [] }, post: { body: 'function post() { }', args: [], thisVars: [], localVars: [] }, funcName: 'addOne', blockSize: 64, debug: false }; const compiled = compiler(procedure); console.log(typeof compiled); // function
Debug
Known issues
breakingProcedure object must have exactly specified fields; missing or extra fields cause errors.
fix
Ensure procedure object includes all required fields: args, pre, body, post, funcName, blockSize, debug.
affects: >=1.0.0
deprecatedThis package is deprecated in favor of using the higher-level cwise API directly. Direct use is not recommended.
fix
Use cwise package instead of calling cwise-compiler directly.
affects: >=1.0.0
gotchaThe pre, body, post functions must be parsed objects with specific structure (body, args, thisVars, localVars), not raw functions.
fix
Use cwise-parser to parse raw function strings into the required format, or ensure you provide correctly structured objects.
affects: >=1.0.0
gotchaThe compiled function expects ndarray arguments in the order specified by args; mismatched types cause runtime errors.
fix
Match the args array to the types and order of arrays passed to the compiled function.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'body' of undefined
Missing or misspelled 'body' field in the procedure object; likely a typo in pre/body/post.
fix
Check that the procedure object has correctly formed pre, body, post sub-objects each with a 'body' string property.
Error: Invalid args array passed to compiler
The args array contains unsupported type strings or numbers.
fix
Ensure args is an array of strings like 'array', 'scalar', 'index', 'shape', etc., as defined by cwise.
ReferenceError: a is not defined (in compiled function)
The body function uses variable 'a' but it is not listed in localVars or args.
fix
Add 'a' to the localVars array of the corresponding pre/body/post object, or ensure it's an argument.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
cwise-parseroptionalUsed to parse procedure code if not already parsed; optional if user provides parsed functions
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
cwise-compiler — npm install cwise-compiler · libregistry