Socket
Book a DemoInstallSign in
Socket

bblfsh

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bblfsh

javascript bblfsh client

0.1.2
latest
npmnpm
Version published
Maintainers
1
Created
Source

Bblfsh javascript client

  • use web grpc to call bblfsh
  • use libuast compiled to WASM for uast filtering

Installation

yarn add bblfsh

The WASM module from node_modules/dist/libuast.wasm must be available as /libuast.wasm in a browser.

It's possible to change the public path to the file like this:

const libuast = initLibuast({
  locateFile(path) {
    if(path.endsWith('.wasm')) {
      return '/some/other/path/libuast.wasm';
    }
    return path;
  }
});

Usage

Client

import Client from 'bblfsh';

const client = new Client('<web-grpc-address>');

client.parse(sourceCode, filename, language)
  .then(r => /* gRPC response */)
  .catch(err => /* or error */);

Libuast

import { protoToMap, initLibuast } from 'bblfsh';

const libuast = initLibuast();
const uastMapping = protoToMap(uast);

libuast.filter(nodeId, uastMapping, xpathQuery)
  .then(ids => /* list of nodes */)
  .catch(err => /* or error */);

Full API documentation available here: API.md.

Run examples locally

docker-compose up

The example app will be available on http://127.0.0.1:8444

Please check Dockerfile in the app example directory to run it without docker

Backend dependencies without docker

Development:

Requirements:

  • nodejs + yarn
  • python2.7
  • build tools: cmake autoconf libtool automake pkg-config make
  • emscripten (v1.38.8+)
  • protoc

Commands

  • yarn build - build everything
  • yarn build:proto - generate js from protobuf files
  • yarn build:libs - download & build C dependencies for libuast
  • yarn build:wasm- generate WASM & js helper for libuast
  • yarn build:bundle - generate library as a bundle with all dependencies included

FAQs

Package last updated on 23 Jul 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.