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

dumbjs

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

dumbjs

[![Build Status](https://travis-ci.org/fabiosantoscode/dumbjs.svg?branch=master)](https://travis-ci.org/fabiosantoscode/dumbjs)

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

dumbjs

Build Status

WIP: Parts of this repo don't work properly yet. If something is crashing dumbjs and it doesn't seem like an intentional dumbjs-originated limitation, file an issue!

A first pass for js2cpp. Uses browserify's dependencies to flatten the dependency tree into a single file, then makes the file not use closures at all by implementing closures in pure javascript.

This was created because I found it too hard to implement closures in js2cpp, then it became clear that it would be much better to implement them at the javascript level, and make the current js2cpp just work on a simple subset of javascript.

So I made dumbjs. It turns javascript into a simpler subset of itself. The most important transformations:

  • Make the compiled javascript work in an environment without closures
  • Flatten the dependency tree like browserify does, turning it into a single file so js2cpp doesn't need to care about more than one file.
  • Without any name collisions, unwrap functions so as to leave no nested function.
  • Separate definitions from declarations, so that var x = 3 in the global scope becomes var x; x = 3, then put every statement that performs any action (assignment or function call) in the global scope, in order, in a single function called "main", whose last statement will be "return 0".

This document has been invaluable in understanding the difficulties and nuances of implementing closures, and describes complicated problems in a way that's easily understandable.

This wikipedia article describes the main problem of implementing closures, and why you can't store functions and their closures on the stack if you want functions in your language to be first-class.

FAQs

Package last updated on 17 Nov 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