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

cwise-compiler

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cwise-compiler

cwise's internal compiler

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
185K
decreased by-56.94%
Maintainers
1
Weekly downloads
 
Created

What is cwise-compiler?

The cwise-compiler npm package is a tool for compiling high-performance, multidimensional array operations in JavaScript. It allows users to define custom operations on arrays that are optimized for performance, making it suitable for scientific computing, image processing, and other tasks that require efficient manipulation of large datasets.

What are cwise-compiler's main functionalities?

Element-wise Operations

This feature allows you to perform element-wise operations on arrays. In the example, the `add` function adds a scalar value to each element of the input array `b` and stores the result in array `a`.

const cwise = require('cwise-compiler');

const add = cwise({
  args: ['array', 'array', 'scalar'],
  body: function(a, b, c) {
    a = b + c;
  }
});

const a = [1, 2, 3];
const b = [4, 5, 6];
add(a, b, 10);
console.log(a); // Output: [14, 15, 16]

Custom Reduction Operations

This feature allows you to define custom reduction operations. In the example, the `sum` function calculates the sum of all elements in the input array `a`.

const cwise = require('cwise-compiler');

const sum = cwise({
  args: ['array'],
  pre: function() {
    this.sum = 0;
  },
  body: function(a) {
    this.sum += a;
  },
  post: function() {
    return this.sum;
  }
});

const a = [1, 2, 3, 4];
const result = sum(a);
console.log(result); // Output: 10

Conditional Operations

This feature allows you to perform conditional operations on arrays. In the example, the `threshold` function sets elements of the input array `a` to 0 if they are less than the scalar threshold value `t`.

const cwise = require('cwise-compiler');

const threshold = cwise({
  args: ['array', 'scalar'],
  body: function(a, t) {
    if (a < t) {
      a = 0;
    }
  }
});

const a = [1, 5, 3, 7];
threshold(a, 4);
console.log(a); // Output: [0, 5, 0, 7]

Other packages similar to cwise-compiler

Keywords

FAQs

Package last updated on 18 Jul 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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