Last active
February 11, 2024 23:01
-
-
Save ChrisBAshton/421663416c721f023bc0 to your computer and use it in GitHub Desktop.
Best base for a JavaScript library
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
// shamelessly taken from Imager - https://github.com/BBC-News/Imager.js/blob/master/Imager.js | |
// develop your JavaScript library to support RequireJS/CommonJS/vanilla JavaScript | |
;(function (window, document) { | |
'use strict'; | |
var Imager = function () { | |
}; | |
Imager.prototype = { | |
}; | |
/* global module, exports: true, define */ | |
if (typeof module === 'object' && typeof module.exports === 'object') { | |
// CommonJS, just export | |
module.exports = exports = Imager; | |
} else if (typeof define === 'function' && define.amd) { | |
// AMD support | |
define(function () { return Imager; }); | |
} else if (typeof window === 'object') { | |
// If no AMD and we are in the browser, attach to window | |
window.Imager = Imager; | |
} | |
/* global -module, -exports, -define */ | |
}(window, document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment