New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

nlopt-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlopt-js

NLopt-js is a port of [NLopt](https://nlopt.readthedocs.io/en/latest/) C++ optimization library

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
19
-71.64%
Maintainers
1
Weekly downloads
 
Created
Source

npm version Website shields.io Made with emscripten GitHub license

NLopt-js

NLopt-js is a port of the nlopt C++ optimization library

It uses a WebAssembly compiled subset of the nlopt library, and implements a garbage collection mechanism to manage memory

HomeDocumentation

Usage

NLopt-js can be installed via npm or yarn

npm install nlopt-js
yarn add nlopt-js

In a node application or in the browser (using webpack)

const nlopt = require('nlopt-js')
// ES6: import nlopt from 'nlopt-js'
(async () => {
  await nlopt.ready
  const opt = new nlopt.Optimize(nlopt.Algorithm.LD_SLSQP, 2);
  opt.setMinObjective((x, grad) => {
    if (grad) {
      grad[0] = 0;
      grad[1] = 0.5 / Math.sqrt(x[1]);
    }
    return Math.sqrt(x[1]);
  }, 1e-4);
  const res = opt.optimize([1, 6]);
  // Flush the GC
  nlopt.GC.flush();
})();

Documentation

The documentation is available at NLopt-js

Build

Make sure Emscripten is intalled & activated in your terminal session

source path/to/emsdk/emsdk_env.sh
./emcc -v

Dowload the latest version of the nlopt library and extract it under

lib/nlopt

Now build a bytecode shared library

mkdir build; cd build
emcmake cmake ..
emmake make

It should generate a shared library bytecode file named libnlopt.bc

Now to compile the wasm binary, run the following command

mkdir build
emcc -I lib/nlopt/build -I lib/nlopt/src/api  -Isrc lib/nlopt/build/libnlopt.a -s DISABLE_EXCEPTION_CATCHING=0 -s ASSERTIONS=0 -O3 -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 --bind -o build/nlopt_gen.js src/cpp/embind.cc 

Generate the documentation

The documentation is generated from classes descriptions using documentation.js

documentation build src/classes/ -f json -o docs/doc.json

Keywords

constraint

FAQs

Package last updated on 30 Nov 2020

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