Created
November 1, 2014 21:48
-
-
Save loonison123/d2094ed86fc3946e5b63 to your computer and use it in GitHub Desktop.
JavaScript module shared between node or browser
This file contains hidden or 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
| (function(exports){ | |
| // Only allow files uploaded below a maximum size | |
| exports.isValidSize = function(sourceSize){ | |
| var maxSize = 1024 * 1024 * 10; // 10MB | |
| return sourceSize <= maxSize; | |
| }; | |
| })(typeof exports === 'undefined'? this['lib.image']={}: exports); | |
| // ----------------------------------------------------------------- | |
| // Use in Node.JS | |
| var imageHelper = require('lib.image'); | |
| imageHelper.isValidSize(1024); // true | |
| // Use client side | |
| // <script src="localhost:3000/lib.image.js"></script> | |
| <script> | |
| var isValidSize = lib.image.isValidSize(1024); // true | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment