If you've ever built a mock terminal application you'll know the pains that exist by not having a terminal coloring helper.
So here is a very basic one for the jQuery Terminal library.
function INFO (msg) {
function contains (string, map) { | |
var results = [] | |
var value | |
for (var key in map) { | |
value = key | |
if (typeof map.length !== 'undefined') { | |
key = map[key] | |
} |
Consolidated list and reference of error message signatures from commonly used Node.js libraries as I got tired of searching through source code / logging to ensure their commonly undocumented error message signatures.
// var ListComponent = m.component({ ... }) -> component | |
// var list = ListComponent() -> component instance | |
// list.view() -> view | |
m.component = function (component) { | |
return function (options, content) { | |
var controller = new component.controller(options) | |
controller.view = function () { | |
return component.view(controller, arguments[0] || options, arguments[1] || content) | |
} |
m.observable = (el={}) -> | |
_id = 0 | |
callbacks = {} | |
el.on = (events, fn) -> | |
if typeof fn is 'function' | |
fn._id = if typeof fn._id is 'undefined' then _id++ else fn._id | |
events.replace /\s+/g, (name, pos) -> | |
callbacks[][name].push fn | |
fn.typed = pos > 0 |
var m = require('mithril') | |
var h = require('virtual-dom/h') | |
var diff = require('virtual-dom/diff') | |
var patch = require('virtual-dom/patch') | |
var createElement = require('virtual-dom/create-element') | |
var validator = require('har-validator') | |
var app = {} | |
app.Har = function (data) { |
m.validator = function (model, validations) { | |
this.errors = {} | |
this.validations = validations | |
this.model = model | |
} | |
m.validator.prototype.hasErrors = function () { | |
return Object.keys(this.errors).length | |
} |
flo = flow | |
// Add method signature and arguments to be invoked | |
.add(/* [name, ]function[, arguments...] */) | |
// Attach thenable to previous method signature | |
.then(function () { | |
// skip(/* string name | int groups */) | |
flo.skip('name') // this.skip vs flo.skip vs (skip argument on argument list, after next) | |
// next(/* string name | int group */) |