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

symtable.js

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

symtable.js

An imperative symbol table library in Javascript

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

symtable.js

An imperative symbol table library in Javascript

Installation

Requires ES6.

npm install symtable.js

Usage

var Symtable = require('symtable.js');

var globalIds = new Map();
globalIds.set('window', 1);
globalIds.set('document', 2);

// Initialize a new symbol table with a map of symbols in the global scope.
var S = new Symtable(globalIds);

// Start a new nested scope
S.enterScope();

// Add a symbol to the table
S.add('a', '3');
S.add('b', 4);

// Find the value of a Symbol
S.find('a'); // 3
S.find('k'); // null

// Check the current scope for a given symbol
S.checkScope('a'); // true
S.checkScope('window'); // false. Since this exists in the global scope and the current scope.

// Exit the current scope
S.exitScope();

API

  • enterScope() - Start a new nested scope.

  • add(x, y) - Add a new symbol x with associated data y.

  • find(x) - Finds current x in the whole symbol table using the most closely nested rule. Returns null otherwise.

  • checkScope(x) - Returns true if x is defined in the current scope.

  • exitScope() - Exit the current scope

Keywords

FAQs

Package last updated on 20 Sep 2015

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