From b1d8309717f3cb8ced8e1b2830fbd44dd149b7e8 Mon Sep 17 00:00:00 2001 From: Milk Lee Date: Wed, 6 May 2015 15:27:03 -0700 Subject: [PATCH] AMD support --- .travis.yml | 2 +- bits/00_header.js | 23 ++++++++++++++++++++--- bits/99_footer.js | 2 +- crc32.flow.js | 25 +++++++++++++++++++++---- crc32.js | 24 ++++++++++++++++++++---- ctest/crc32.js | 24 ++++++++++++++++++++---- 6 files changed, 83 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 381b0d0..c6ea55e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: + - "iojs" - "0.11" - "0.10" - - "0.8" before_install: - "npm install -g mocha crc-32 benchmark ansi" - "npm install blanket" diff --git a/bits/00_header.js b/bits/00_header.js index 8d5d5da..eef3f05 100644 --- a/bits/00_header.js +++ b/bits/00_header.js @@ -1,5 +1,22 @@ -/* crc32.js (C) 2014 SheetJS -- http://sheetjs.com */ +/* crc32.js (C) 2014-2015 SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ -var CRC32 = {}; +var CRC32; /*:: declare var DO_NOT_EXPORT_CRC: any; */ -(function(CRC32) { +/*:: declare var define: any; */ +(function (factory) { + if(typeof DO_NOT_EXPORT_CRC === 'undefined') { + if('object' === typeof exports) { + factory(exports); + } else if ('function' === typeof define && define.amd) { + define(function () { + var module = {}; + factory(module); + return module; + }); + } else { + factory(CRC32 = {}); + } + } else { + factory(CRC32 = {}); + } +}(function(CRC32) { diff --git a/bits/99_footer.js b/bits/99_footer.js index 802d058..be4600a 100644 --- a/bits/99_footer.js +++ b/bits/99_footer.js @@ -1 +1 @@ -})(typeof exports !== "undefined" && typeof DO_NOT_EXPORT_CRC === 'undefined' ? exports : CRC32); +})); diff --git a/crc32.flow.js b/crc32.flow.js index 8f62636..cd5418a 100644 --- a/crc32.flow.js +++ b/crc32.flow.js @@ -1,8 +1,25 @@ -/* crc32.js (C) 2014 SheetJS -- http://sheetjs.com */ +/* crc32.js (C) 2014-2015 SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ -var CRC32 = {}; +var CRC32; /*:: declare var DO_NOT_EXPORT_CRC: any; */ -(function(CRC32) { +/*:: declare var define: any; */ +(function (factory) { + if(typeof DO_NOT_EXPORT_CRC === 'undefined') { + if('object' === typeof exports) { + factory(exports); + } else if ('function' === typeof define && define.amd) { + define(function () { + var module = {}; + factory(module); + return module; + }); + } else { + factory(CRC32 = {}); + } + } else { + factory(CRC32 = {}); + } +}(function(CRC32) { CRC32.version = '0.3.0'; /*:: type CRC32Type = number; @@ -97,4 +114,4 @@ CRC32.table = table; CRC32.bstr = crc32_bstr; CRC32.buf = crc32_buf; CRC32.str = crc32_str; -})(typeof exports !== "undefined" && typeof DO_NOT_EXPORT_CRC === 'undefined' ? exports : CRC32); +})); diff --git a/crc32.js b/crc32.js index 3f00ceb..a1ca898 100644 --- a/crc32.js +++ b/crc32.js @@ -1,7 +1,23 @@ -/* crc32.js (C) 2014 SheetJS -- http://sheetjs.com */ +/* crc32.js (C) 2014-2015 SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ -var CRC32 = {}; -(function(CRC32) { +var CRC32; +(function (factory) { + if(typeof DO_NOT_EXPORT_CRC === 'undefined') { + if('object' === typeof exports) { + factory(exports); + } else if ('function' === typeof define && define.amd) { + define(function () { + var module = {}; + factory(module); + return module; + }); + } else { + factory(CRC32 = {}); + } + } else { + factory(CRC32 = {}); + } +}(function(CRC32) { CRC32.version = '0.3.0'; /* see perf/crc32table.js */ function signed_crc_table() { @@ -91,4 +107,4 @@ CRC32.table = table; CRC32.bstr = crc32_bstr; CRC32.buf = crc32_buf; CRC32.str = crc32_str; -})(typeof exports !== "undefined" && typeof DO_NOT_EXPORT_CRC === 'undefined' ? exports : CRC32); +})); diff --git a/ctest/crc32.js b/ctest/crc32.js index 3f00ceb..a1ca898 100644 --- a/ctest/crc32.js +++ b/ctest/crc32.js @@ -1,7 +1,23 @@ -/* crc32.js (C) 2014 SheetJS -- http://sheetjs.com */ +/* crc32.js (C) 2014-2015 SheetJS -- http://sheetjs.com */ /* vim: set ts=2: */ -var CRC32 = {}; -(function(CRC32) { +var CRC32; +(function (factory) { + if(typeof DO_NOT_EXPORT_CRC === 'undefined') { + if('object' === typeof exports) { + factory(exports); + } else if ('function' === typeof define && define.amd) { + define(function () { + var module = {}; + factory(module); + return module; + }); + } else { + factory(CRC32 = {}); + } + } else { + factory(CRC32 = {}); + } +}(function(CRC32) { CRC32.version = '0.3.0'; /* see perf/crc32table.js */ function signed_crc_table() { @@ -91,4 +107,4 @@ CRC32.table = table; CRC32.bstr = crc32_bstr; CRC32.buf = crc32_buf; CRC32.str = crc32_str; -})(typeof exports !== "undefined" && typeof DO_NOT_EXPORT_CRC === 'undefined' ? exports : CRC32); +}));