Skip to content

Instantly share code, notes, and snippets.

View ericf's full-sized avatar

Eric Ferraiuolo ericf

View GitHub Profile
'use strict';
var fs = require('fs'),
path = require('path'),
Promise = require('es6-promise').Promise,
zlib = require('zlib');
var utils = require('../utils');
module.exports = function fileSizes(pureDir, callback) {
/**
* Sanitize URL — Validate it looks like a URL, then make it less dirty.
*
* Oddnut Software
* Copyright (c) 2010 Eric Ferraiuolo - http://eric.ferraiuolo.name
* MIT License - http://www.opensource.org/licenses/mit-license.php
*
* Examples:
*
* 'Http://WWW.example.com/' » 'http://www.example.com/'
'use strict';
var serialize = require('./serialize');
module.exports = Exposed;
function Exposed() {
Object.defineProperties(this, {
// Brand with constructor.
'@exposed': {value: Exposed},
Exposed.prototype._getApplicableNamespaces = function () {
var namespaces = this.__namespaces__.concat(),
proto = Object.getPrototypeOf(this);
function isApplicable(namespace) {
return !namespaces.some(function (ns) {
var nsRegex = new RegExp('^' + ns + '(?:$|\\..+)');
return nsRegex.test(namespace);
});
}
app.expose('foo', 'window.foo');
console.log(res.locals.state); // => window.foo = "foo";
app.expose('bar', 'window.bar');
console.log(res.locals.state); // => window.foo = "foo";
exports
.local
✓ should have a .local property
✓ should be the string "state"
.namespace
✓ should have a .namespace property
✓ should be null
.extend
✓ should have a .extend property
✓ should respond to .extend()
'use strict';
var fs = require('fs'),
path = require('path'),
parseCSS = require('css-parse'),
Promise = require('es6-promise').Promise;
module.exports = function gridUnits(pureDir, callback) {
readUnits(path.join(pureDir, 'grids-units.css'))
.then(parseCSS)
'use strict';
var fs = require('fs'),
path = require('path'),
Promise = require('es6-promise').Promise,
zlib = require('zlib');
module.exports = function fileSizes(pureDir, callback) {
getModules(pureDir)
.then(getFileSizes.bind(null, pureDir))
'use strict';
var fs = require('fs'),
path = require('path'),
Promise = require('es6-promise').Promise,
zlib = require('zlib');
module.exports = filesizes;
// -----------------------------------------------------------------------------
> var exposed = Exposed.create();
undefined
> var obj = {};
undefined
> Object.defineProperty(obj, 'foo', {
..... enumerable: true,
..... get: function () { return 'FOO'; }
..... });
{ foo: [Getter] }
> exposed.add('foo', obj);