This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wrapper v0.0.3 | |
// http://github.com/CandidBlend/wrapper | |
(function(n){"use strict";function e(n){return n.charAt(0).toUpperCase()+n.slice(1)}n.wrapper=function(t,i,r){var u="function"==typeof define&&define.amd?define:function(t,i,r){i=i.map(function(t){return"jquery"===t?n[$]:n[e(t)]}),n[e(t)]=r.apply(null,i)};return function(n){n(t,i,r)}(u)}})(window); | |
wrapper('logger', [], function() { | |
'use strict'; | |
var _hasConsole = (typeof(window.console) === 'object'); | |
return { | |
log: function(msg) { | |
if (!_hasConsole) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wrapper('skeleton', ['logger'], function(Logger) { | |
'use strict'; | |
function Skeleton(params) { | |
params = params || {}; | |
this.name = params.name || 'default'; | |
this.initialize(); | |
} | |
Skeleton.prototype = { | |
initialize: function() { | |
Logger.log('this skeleton\'s name is %s', this.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wrapper('logger', [], function() { | |
'use strict'; | |
var _hasConsole = (typeof(window.console) === 'object'); | |
return { | |
log: function(msg) { | |
if (!_hasConsole) { | |
return; | |
} | |
var log, args; | |
args = Array.prototype.slice.call(arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
uglify: { | |
options: { | |
banner: '// <%= pkg.name %> v<%= pkg.version %>\n' | |
}, | |
build: { | |
src: 'dist/<%= pkg.name %>-<%= pkg.version %>.js', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "skeleton", | |
"description": "demo for usage in library/module creation with wrapper and grunt for build", | |
"version": "0.0.1", | |
"devDependencies": { | |
"grunt": "0.4.1", | |
"grunt-contrib-uglify": "0.1.1", | |
"grunt-contrib-jshint": "0.2.0", | |
"grunt-contrib-concat": "0.1.3", | |
"grunt-contrib-watch": "0.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @library wrapper.js | |
* @author Edward Hotchkiss <[email protected]> | |
* @contributor Avi Deitcher <[email protected]> | |
* @description wraps any function/module/object/lib within an | |
* AMD-compliant definition if possible, otherwise binding to `window` | |
* @license MIT | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// configure | |
require.config({ | |
baseUrl: './', | |
paths: { | |
'skeleton': 'skeleton' | |
}, | |
shim: { | |
skeleton: { | |
exports: 'Skeleton', | |
deps: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage | |
var skeleton = new Skeleton({ name : 'example2' }); | |
=> this skeleton's name is "skeleton2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compatible with (if available) RequireJS/AMD | |
(function(root) { | |
'use strict'; | |
/* ---- private ---- */ | |
/** | |
* @private _hasConsole | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// private example | |
_log('hi'); | |
=> Uncaught ReferenceError: _log is not defined |