From 64682c50dd9913e863a958b30353a28bf25a2555 Mon Sep 17 00:00:00 2001 From: Alex Gorbatchev Date: Mon, 6 Dec 2010 20:29:57 -0800 Subject: [PATCH] Added RequireJS compatability. --- README.md | 2 +- lib/crc.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 23e27d8..0686d95 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # CRC for node.js -This is a basic port/copy of the JavaScript CRC implementation. +This is a basic port/copy of the JavaScript CRC implementation. The module is compatible with RequireJS. ## Functions diff --git a/lib/crc.js b/lib/crc.js index eef9087..3f7c322 100644 --- a/lib/crc.js +++ b/lib/crc.js @@ -1,4 +1,7 @@ -(function() +// make this module compatible with RequireJS +typeof(define) == "undefined" && (define = function(deps, factory) { module.exports = factory.apply(this, deps.map(require)); }); + +define([], function() { // CRC-8 in table form // @@ -344,7 +347,7 @@ return str2+str1; } - module.exports = { + return { 'crc8' : crc8Str, 'crcArc' : crcArcStr, 'crc16' : crc16Str, @@ -354,5 +357,4 @@ 'hex16' : hex16, 'hex32' : hex32 }; - -})(); \ No newline at end of file +});