From 2af7e28535b4b356460886a3f56f71e2f9decdd7 Mon Sep 17 00:00:00 2001 From: Eric Hamilton Date: Tue, 27 Nov 2012 09:21:42 -0800 Subject: [PATCH] Add browserify support. Clean up package. --- dist/browser-cuid.js | 9 ++++----- dist/node-cuid.js | 9 ++++----- grunt.js | 3 ++- package.json | 8 ++++---- src/footer.js | 5 +++-- src/head.js | 4 +--- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/dist/browser-cuid.js b/dist/browser-cuid.js index dbee02d..d815cb8 100644 --- a/dist/browser-cuid.js +++ b/dist/browser-cuid.js @@ -10,9 +10,7 @@ * MIT License */ -/*global window, navigator, document, require, process*/ -var global = global || this, module = module || undefined; - +/*global window, navigator, document, require, process, module */ (function (app) { 'use strict'; var namespace = 'cuid', @@ -88,9 +86,10 @@ var global = global || this, module = module || undefined; // don't change anything from here down. if (app.register) { app.register(namespace, api); + } else if (typeof module !== 'undefined') { + module.exports = api; } else { - namespace = app.exports ? 'exports' : namespace; app[namespace] = api; } -}(global.applitude || module || this)); +}(this.applitude || this)); diff --git a/dist/node-cuid.js b/dist/node-cuid.js index 5235400..debe69a 100644 --- a/dist/node-cuid.js +++ b/dist/node-cuid.js @@ -10,9 +10,7 @@ * MIT License */ -/*global window, navigator, document, require, process*/ -var global = global || this, module = module || undefined; - +/*global window, navigator, document, require, process, module */ (function (app) { 'use strict'; var namespace = 'cuid', @@ -83,9 +81,10 @@ var global = global || this, module = module || undefined; // don't change anything from here down. if (app.register) { app.register(namespace, api); + } else if (typeof module !== 'undefined') { + module.exports = api; } else { - namespace = app.exports ? 'exports' : namespace; app[namespace] = api; } -}(global.applitude || module || this)); +}(this.applitude || this)); diff --git a/grunt.js b/grunt.js index af5b2a0..1ab2160 100644 --- a/grunt.js +++ b/grunt.js @@ -46,6 +46,7 @@ module.exports = function(grunt) { "node-cuid": ['test/node-cuid-test.js'] } }); - grunt.registerTask('default', 'concat lint qunit test'); + grunt.registerTask('testall', 'qunit test'); + grunt.registerTask('default', 'concat lint'); grunt.registerTask('install', 'concat'); }; diff --git a/package.json b/package.json index bef0de3..0deaacd 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "cuid", - "version": "1.1.6", + "version": "1.1.7", "description": "Collission-resistant ids optimized for horizontal scaling and performance. For node and browsers.", "author": { "name": "Eric Elliott", "url": "http://ericleads.com" }, "main": "./dist/node-cuid.js", + "browserify": "./dist/browser-cuid.js", "keywords": [ "uid", "unique id", @@ -23,13 +24,12 @@ "src": "./src", "test": "./test" }, - "dependencies": { + "devDependencies": { "applitude": "~0.x.x", "grunt": "~0.3.x" }, "scripts": { - "postinstall": "grunt install", - "test": "grunt" + "test": "grunt testall" }, "engines": { "node": "~0.x.x" diff --git a/src/footer.js b/src/footer.js index 01bca0a..daf009f 100644 --- a/src/footer.js +++ b/src/footer.js @@ -2,9 +2,10 @@ // don't change anything from here down. if (app.register) { app.register(namespace, api); + } else if (typeof module !== 'undefined') { + module.exports = api; } else { - namespace = app.exports ? 'exports' : namespace; app[namespace] = api; } -}(global.applitude || module || this)); +}(this.applitude || this)); diff --git a/src/head.js b/src/head.js index 022d549..786b1f4 100644 --- a/src/head.js +++ b/src/head.js @@ -10,9 +10,7 @@ * MIT License */ -/*global window, navigator, document, require, process*/ -var global = global || this, module = module || undefined; - +/*global window, navigator, document, require, process, module */ (function (app) { 'use strict'; var namespace = 'cuid',