diff --git a/Makefile b/Makefile index a4ce49c..307f0b1 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ build: components lib @rm -rf dist @mkdir dist @node_modules/.bin/coffee -b -o dist -c lib/*.coffee - @node_modules/.bin/component build --standalone APPNAME - @mv build/build.js APPNAME.js + @node_modules/.bin/component build --standalone no + @mv build/build.js no.js @rm -rf build - @node_modules/.bin/uglifyjs -nc --unsafe -mt -o APPNAME.min.js APPNAME.js - @echo "File size (minified): " && cat APPNAME.min.js | wc -c - @echo "File size (gzipped): " && cat APPNAME.min.js | gzip -9f | wc -c - @cp ./APPNAME.js ./examples/ + @node_modules/.bin/uglifyjs -nc --unsafe -mt -o no.min.js no.js + @echo "File size (minified): " && cat no.min.js | wc -c + @echo "File size (gzipped): " && cat no.min.js | gzip -9f | wc -c + @cp ./no.js ./examples/ test: build lib @node_modules/.bin/mocha --compilers coffee:coffee-script @@ -17,14 +17,14 @@ components: component.json @node_modules/.bin/component install --dev docs: lib - @node_modules/.bin/lidoc README.md manual/*.md lib/*.coffee --output docs --github wearefractal/APPNAME + @node_modules/.bin/lidoc README.md manual/*.md lib/*.coffee --output docs --github wearefractal/no docs.deploy: docs @cd docs && \ git init . && \ git add . && \ git commit -m "Update documentation"; \ - git push "https://github.com/wearefractal/APPNAME" master:gh-pages --force && \ + git push "https://github.com/wearefractal/no" master:gh-pages --force && \ rm -rf .git clean: diff --git a/README.md b/README.md index 49fe74e..eb279e8 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ -![status](https://secure.travis-ci.org/wearefractal/APPNAME.png?branch=master) +![status](https://secure.travis-ci.org/wearefractal/no.png?branch=master) ## Information - + - - + @@ -18,14 +17,11 @@ ## Usage -```coffee-script -NOTHING HERE YET +```javascript +var no = require('no'); +console.log(no); // no ``` -## Examples - -You can view more examples in the [example folder.](https://github.com/wearefractal/APPNAME/tree/master/examples) - ## LICENSE (MIT License) diff --git a/component.json b/component.json index 92511a9..fa955ae 100644 --- a/component.json +++ b/component.json @@ -1,5 +1,5 @@ { - "name": "APPNAME", + "name": "no", "version": "0.0.1", "dependencies": { "component/emitter":"*" diff --git a/dist/main.js b/dist/main.js new file mode 100644 index 0000000..32ab144 --- /dev/null +++ b/dist/main.js @@ -0,0 +1,2 @@ +// Generated by CoffeeScript 1.6.2 +module.exports = "no"; diff --git a/examples/no.js b/examples/no.js new file mode 100644 index 0000000..0563c5c --- /dev/null +++ b/examples/no.js @@ -0,0 +1,396 @@ +;(function(){ + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("component-indexof/index.js", function(exports, require, module){ + +var indexOf = [].indexOf; + +module.exports = function(arr, obj){ + if (indexOf) return arr.indexOf(obj); + for (var i = 0; i < arr.length; ++i) { + if (arr[i] === obj) return i; + } + return -1; +}; +}); +require.register("component-emitter/index.js", function(exports, require, module){ + +/** + * Module dependencies. + */ + +var index = require('indexof'); + +/** + * Expose `Emitter`. + */ + +module.exports = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +}; + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks[event] = this._callbacks[event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + var self = this; + this._callbacks = this._callbacks || {}; + + function on() { + self.off(event, on); + fn.apply(this, arguments); + } + + fn._off = on; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks[event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks[event]; + return this; + } + + // remove specific handler + var i = index(callbacks, fn._off || fn); + if (~i) callbacks.splice(i, 1); + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1) + , callbacks = this._callbacks[event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks[event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; + +}); +require.register("no/dist/main.js", function(exports, require, module){ +// Generated by CoffeeScript 1.6.2 +module.exports = "no"; + +}); +require.alias("component-emitter/index.js", "no/deps/emitter/index.js"); +require.alias("component-indexof/index.js", "component-emitter/deps/indexof/index.js"); + +require.alias("no/dist/main.js", "no/index.js"); + +if (typeof exports == "object") { + module.exports = require("no"); +} else if (typeof define == "function" && define.amd) { + define(function(){ return require("no"); }); +} else { + window["no"] = require("no"); +}})(); \ No newline at end of file diff --git a/lib/main.coffee b/lib/main.coffee index 7c6d6c7..13fd97e 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -1 +1 @@ -module.exports = {} \ No newline at end of file +module.exports = "no" \ No newline at end of file diff --git a/no.js b/no.js new file mode 100644 index 0000000..0563c5c --- /dev/null +++ b/no.js @@ -0,0 +1,396 @@ +;(function(){ + +/** + * Require the given path. + * + * @param {String} path + * @return {Object} exports + * @api public + */ + +function require(path, parent, orig) { + var resolved = require.resolve(path); + + // lookup failed + if (null == resolved) { + orig = orig || path; + parent = parent || 'root'; + var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); + err.path = orig; + err.parent = parent; + err.require = true; + throw err; + } + + var module = require.modules[resolved]; + + // perform real require() + // by invoking the module's + // registered function + if (!module.exports) { + module.exports = {}; + module.client = module.component = true; + module.call(this, module.exports, require.relative(resolved), module); + } + + return module.exports; +} + +/** + * Registered modules. + */ + +require.modules = {}; + +/** + * Registered aliases. + */ + +require.aliases = {}; + +/** + * Resolve `path`. + * + * Lookup: + * + * - PATH/index.js + * - PATH.js + * - PATH + * + * @param {String} path + * @return {String} path or null + * @api private + */ + +require.resolve = function(path) { + if (path.charAt(0) === '/') path = path.slice(1); + var index = path + '/index.js'; + + var paths = [ + path, + path + '.js', + path + '.json', + path + '/index.js', + path + '/index.json' + ]; + + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + if (require.modules.hasOwnProperty(path)) return path; + } + + if (require.aliases.hasOwnProperty(index)) { + return require.aliases[index]; + } +}; + +/** + * Normalize `path` relative to the current path. + * + * @param {String} curr + * @param {String} path + * @return {String} + * @api private + */ + +require.normalize = function(curr, path) { + var segs = []; + + if ('.' != path.charAt(0)) return path; + + curr = curr.split('/'); + path = path.split('/'); + + for (var i = 0; i < path.length; ++i) { + if ('..' == path[i]) { + curr.pop(); + } else if ('.' != path[i] && '' != path[i]) { + segs.push(path[i]); + } + } + + return curr.concat(segs).join('/'); +}; + +/** + * Register module at `path` with callback `definition`. + * + * @param {String} path + * @param {Function} definition + * @api private + */ + +require.register = function(path, definition) { + require.modules[path] = definition; +}; + +/** + * Alias a module definition. + * + * @param {String} from + * @param {String} to + * @api private + */ + +require.alias = function(from, to) { + if (!require.modules.hasOwnProperty(from)) { + throw new Error('Failed to alias "' + from + '", it does not exist'); + } + require.aliases[to] = from; +}; + +/** + * Return a require function relative to the `parent` path. + * + * @param {String} parent + * @return {Function} + * @api private + */ + +require.relative = function(parent) { + var p = require.normalize(parent, '..'); + + /** + * lastIndexOf helper. + */ + + function lastIndexOf(arr, obj) { + var i = arr.length; + while (i--) { + if (arr[i] === obj) return i; + } + return -1; + } + + /** + * The relative require() itself. + */ + + function localRequire(path) { + var resolved = localRequire.resolve(path); + return require(resolved, parent, path); + } + + /** + * Resolve relative to the parent. + */ + + localRequire.resolve = function(path) { + var c = path.charAt(0); + if ('/' == c) return path.slice(1); + if ('.' == c) return require.normalize(p, path); + + // resolve deps by returning + // the dep in the nearest "deps" + // directory + var segs = parent.split('/'); + var i = lastIndexOf(segs, 'deps') + 1; + if (!i) i = 0; + path = segs.slice(0, i + 1).join('/') + '/deps/' + path; + return path; + }; + + /** + * Check if module is defined at `path`. + */ + + localRequire.exists = function(path) { + return require.modules.hasOwnProperty(localRequire.resolve(path)); + }; + + return localRequire; +}; +require.register("component-indexof/index.js", function(exports, require, module){ + +var indexOf = [].indexOf; + +module.exports = function(arr, obj){ + if (indexOf) return arr.indexOf(obj); + for (var i = 0; i < arr.length; ++i) { + if (arr[i] === obj) return i; + } + return -1; +}; +}); +require.register("component-emitter/index.js", function(exports, require, module){ + +/** + * Module dependencies. + */ + +var index = require('indexof'); + +/** + * Expose `Emitter`. + */ + +module.exports = Emitter; + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +}; + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks[event] = this._callbacks[event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + var self = this; + this._callbacks = this._callbacks || {}; + + function on() { + self.off(event, on); + fn.apply(this, arguments); + } + + fn._off = on; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks[event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks[event]; + return this; + } + + // remove specific handler + var i = index(callbacks, fn._off || fn); + if (~i) callbacks.splice(i, 1); + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1) + , callbacks = this._callbacks[event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks[event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; + +}); +require.register("no/dist/main.js", function(exports, require, module){ +// Generated by CoffeeScript 1.6.2 +module.exports = "no"; + +}); +require.alias("component-emitter/index.js", "no/deps/emitter/index.js"); +require.alias("component-indexof/index.js", "component-emitter/deps/indexof/index.js"); + +require.alias("no/dist/main.js", "no/index.js"); + +if (typeof exports == "object") { + module.exports = require("no"); +} else if (typeof define == "function" && define.amd) { + define(function(){ return require("no"); }); +} else { + window["no"] = require("no"); +}})(); \ No newline at end of file diff --git a/no.min.js b/no.min.js new file mode 100644 index 0000000..6c02e28 --- /dev/null +++ b/no.min.js @@ -0,0 +1 @@ +(function(){function t(e,r,n){var i=t.resolve(e);if(null==i){n=n||e,r=r||"root";var o=Error('Failed to require "'+n+'" from "'+r+'"');throw o.path=n,o.parent=r,o.require=!0,o}var s=t.modules[i];return s.exports||(s.exports={},s.client=s.component=!0,s.call(this,s.exports,t.relative(i),s)),s.exports}t.modules={},t.aliases={},t.resolve=function(e){"/"===e.charAt(0)&&(e=e.slice(1));for(var r=e+"/index.js",n=[e,e+".js",e+".json",e+"/index.js",e+"/index.json"],i=0;n.length>i;i++){var e=n[i];if(t.modules.hasOwnProperty(e))return e}return t.aliases.hasOwnProperty(r)?t.aliases[r]:void 0},t.normalize=function(t,e){var r=[];if("."!=e.charAt(0))return e;t=t.split("/"),e=e.split("/");for(var n=0;e.length>n;++n)".."==e[n]?t.pop():"."!=e[n]&&""!=e[n]&&r.push(e[n]);return t.concat(r).join("/")},t.register=function(e,r){t.modules[e]=r},t.alias=function(e,r){if(!t.modules.hasOwnProperty(e))throw Error('Failed to alias "'+e+'", it does not exist');t.aliases[r]=e},t.relative=function(e){function r(t,e){for(var r=t.length;r--;)if(t[r]===e)return r;return-1}function n(r){var i=n.resolve(r);return t(i,e,r)}var i=t.normalize(e,"..");return n.resolve=function(n){var o=n.charAt(0);if("/"==o)return n.slice(1);if("."==o)return t.normalize(i,n);var s=e.split("/"),a=r(s,"deps")+1;return a||(a=0),n=s.slice(0,a+1).join("/")+"/deps/"+n},n.exists=function(e){return t.modules.hasOwnProperty(n.resolve(e))},n},t.register("component-indexof/index.js",function(t,e,r){var n=[].indexOf;r.exports=function(t,e){if(n)return t.indexOf(e);for(var r=0;t.length>r;++r)if(t[r]===e)return r;return-1}}),t.register("component-emitter/index.js",function(t,e,r){function n(t){return t?i(t):void 0}function i(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}var o=e("indexof");r.exports=n,n.prototype.on=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){n.off(t,r),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},e._off=r,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;var n=o(r,e._off||e);return~n&&r.splice(n,1),this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks[t];if(r){r=r.slice(0);for(var n=0,i=r.length;i>n;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}}),t.register("no/dist/main.js",function(t,e,r){r.exports="no"}),t.alias("component-emitter/index.js","no/deps/emitter/index.js"),t.alias("component-indexof/index.js","component-emitter/deps/indexof/index.js"),t.alias("no/dist/main.js","no/index.js"),"object"==typeof exports?module.exports=t("no"):"function"==typeof define&&define.amd?define(function(){return t("no")}):window.no=t("no")})(); \ No newline at end of file diff --git a/package.json b/package.json index 05b29f0..252fec9 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name":"APPNAME", + "name":"no", "description":"Nothing here yet", "version":"0.0.1", - "homepage":"http://github.com/wearefractal/APPNAME", - "repository":"git://github.com/wearefractal/APPNAME.git", + "homepage":"http://github.com/wearefractal/no", + "repository":"git://github.com/wearefractal/no.git", "author":"Fractal (http://wearefractal.com/)", "main":"./index.js", @@ -26,7 +26,7 @@ "licenses":[ { "type":"MIT", - "url":"http://github.com/wearefractal/APPNAME/raw/master/LICENSE" + "url":"http://github.com/wearefractal/no/raw/master/LICENSE" } ] } diff --git a/test/main.coffee b/test/main.coffee index 0e82336..77c92a8 100644 --- a/test/main.coffee +++ b/test/main.coffee @@ -1,10 +1,9 @@ -APPNAME = require '../' +mod = require '../' should = require 'should' require 'mocha' -describe 'APPNAME', -> - describe 'FUNCTIONNAME()', -> - it 'should TASKNAME', (done) -> - should.exist true - true.should.equal.true +describe 'no', -> + describe 'the module', -> + it 'should function properly', (done) -> + mod.should.equal "no" done() \ No newline at end of file
PackageAPPNAMEPackageno
DescriptionNOTHING HERE YETis no
Node Version