🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

cwise-compiler

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
c

cwise-compiler

cwise's internal compiler

1.1.3
latest
100

Supply Chain Security

100

Vulnerability

75

Quality

82

Maintenance

100

License

Uses eval

Supply chain risk

Package uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.

Found 1 instance in 1 package

Version published
Weekly downloads
443K
-10.2%
Maintainers
6
Weekly downloads
 
Created
Issues
0

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

FAQs

Package last updated on 17 May 2017

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