The JavaScript blog.


libraries JSON ui database themes memory

JSON File Store, Purplecoat.js

Posted on .

JSON File Store

I've been emailed a selection of in-memory databases, spurred on by last week's LokiJS post. JSON file store (npm: jfs, License: MIT) by flosse can save JSON to files, and it also has a pretty option for producing readable output.

It can generate IDs using the node-uuid module, but it also works with custom IDs as well. It supports synchronous operations for saving and getting items. The basic usage looks like this:

var Store = require('jfs');  
var db = new Store('data');

var d = {  
  foo: 'bar'

// Save with custom ID
db.save('anId', d, function(err) {  
  // Now the data is stored in the file data/anId.json

// Save with generated ID
db.save(d, function(err, id) {  
  // id is a unique ID

You can toggle memory-only mode with the type: 'memory' option. I thought this project seemed like something that might be useful if you've got configuration or small data files files that are user editable, perhaps in a redistributable web application or daemon.


Elle Kasai sent in Purplecoat.js (GitHub: ellekasai / purplecoat.js, License: MIT, Bower: purplecoat.js), a lightweight version of those popover tutorial libraries. It can be applied to an element with the data-purplecoat attribute, and data-purplecoat-label can be used to add a message.

Purplecoat.js is used to document Elle's Shiori Bootstrap theme for Jekyll, which is a clean and minimal Jekyll theme with several built-in colour themes.


testing node modules parsing text debugging memory

memdiff, numerizerJS, Obfuscate.js

Posted on .


memdiff (GitHub: azer / memdiff, License: WTFPL, npm: memdiff) by Azer Koculu is a BDD-style memory leak tool based on memwatch. It can either be used by writing scripts with describe and it, and then running them with memdiff:

function SimpleClass(){}  
var leaks = [];

describe('SimpleClass', function() {  
  it('is leaking', function() {
    leaks.push(new SimpleClass);

  it('is not leaking', function() {
    new SimpleClass;

Or by loading memdiff with require and passing a callback to memdiff. The memwatch module itself has an event-based API, and includes a platform-independent native module -- so both of these projects are tied to Node and won't work in a browser.


numerizerJS (GitHub: bolgovr / numerizerJS, License: MIT, npm: numerizer) by Roman Bolgov is a library for parsing English language string representations of numbers:

var numerizer = require('numerizer');  
numerizer('forty two'); // '42'  

It's currently very simple, and doesn't support browsers out of the box, but I like the fact the author has included Mocha tests. It'd work well alongside other libraries like Moment.js for providing intuitive text-based interfaces.


Obfuscate.js (GitHub: miohtama / obfuscate.js, License: MIT) by Mikko Ohtamaa is a client-side script for replacing text on pages with nonsense that may be more desirable than private information. Mikko suggests this might be useful for making screenshots, so post-processing isn't required to blur out personal information. The obfuscate function takes an optional selector, so either the entire body of a document can be obfuscated, or just the contents of a given selector.

It walks through each child node looking for text nodes, so it's lightweight and doesn't have any dependencies. It also tries to make the text look similar (at a glance) to the original text.