Skip to content

Instantly share code, notes, and snippets.

@alkavan
Last active August 29, 2015 14:01
Show Gist options
  • Save alkavan/b6051e0cf7812ad8cb21 to your computer and use it in GitHub Desktop.
Save alkavan/b6051e0cf7812ad8cb21 to your computer and use it in GitHub Desktop.
Require.js (AMD) Definition Template
/**
* An example how to define library for require.js (AMD)
* Copyright (C) 2014 Igal Alkon
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
(function(window, undefined) {
'use strict';
function factory() {
var ProtoObj = {
text: 'm00',
friction: 0.003,
myMethod: function () {
}
};
return function () {
return Object.create(ProtoObj);
};
}
if(typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
// define as an anonymous module
define([], factory);
} else {
factory();
}
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment