npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vm-titanium

v0.0.1

Published

Implementation of node.js's vm module in Titanium

Downloads

42

Readme

vm-titanium

node.js vm implementation for Titanium. This code is based heavily on James Halliday's vm-browserify, modified for creation of contexts within the Titanium runtime.

This is a work-in-progress; an experimental idea. This is still hacky/clunky, but I'm putting it here to get more eyes on it and see if others can divine more elegant solutions to the same problem. More specifically, anyone who can resolve any of the caveats below gets a digital high five.

install

$ npm install vm-titanium
$ cp ./node_modules/vm-titanium/vm-titanium.js /path/to/titanium_project/Resources
$ cp ./node_modules/vm-titanium/__context.js /path/to/titanium_project/Resources

supported on

So far this has only been tested on the following system, but it's likely to work in other configurations I just haven't tried yet. Log an issue if you have problems using it on any of Appcelerator's supported platforms.

  • TiSDK 3.3.0+
  • iOS 7.1
  • iPhone simulator

usage

var vm = require('vm-titanium');

// essentially just an eval
vm.runInThisContext('1 + 2 + 3', function(err, result) {
	console.log(result); // prints "6"
});

// change/add values from context
var context = vm.createContext({ foo: 'unchanged' });
vm.runInContext('foo="changed";newvalue=123', context, function(err, result) {
	console.log(context.foo);      // prints "changed"
	console.log(context.newvalue); // prints 123
});

// Create and open a Titanium Window. See issue #4 for explanation of why
// Ti and Titanium are manually added to the sandbox.
var sandbox = {
	Ti: Ti,
	Titanium: Titanium
};
var code =
'var win = Ti.UI.createWindow();' +
'win.add(Ti.UI.createView({' +
'  height: Ti.Platform.displayCaps.platformHeight/2,' +
'  backgroundColor: "#00f"' +
'});'
'win.open();'

vm.runInNewContext(code, sandbox, function(err, result) {
	// do other stuff
});

testing

# unit tests and linting
$ grunt

caveats

Not sure if these are surmountable, but take a look at the issue details if you're feeling brave.

  • [issue #2]: runInContext and runInNewContext require you to use a callback, making them unsuitable as drop-in replacements for node.js's synchronous implementations.
  • [issue #3]: Window created when creating a new context is visible, but shouldn't be.
  • [issue #4]: Certain Titanium namespaces always need to be manually copied into the context/sandbox when using runInContext or runInNewContext. (workaround in issue)