Looks like you assign to your own closure?
Typically what I do for libs that don't support CommonJS is :
(function(exports) {
// insert the lib code
// add exports
exports.jsSHA = jsSHA;
})(exports);
Then:
var shalib = require('lib/sha.js");
var mySHA = new shalib.jsSHA(...);
Sometimes I have to drop the closure and just assign the exports.
- Jim
Sent from my iPhone
On Oct 5, 2012, at 9:56 AM, "Wordit" <[email protected]> wrote:
> On Fri, Oct 5, 2012 at 8:53 AM, Jim Klo <[email protected]> wrote:
>> What does jsSHA look like? Does it export something? I think CommonJS uses
>> exports vs export.
>
> Oops, typo, googd catch. However, it changes nothing. I think the
> problem is related to how jsSHA needs to instantiate a new object
> first. From the docs:
>
> "Instantiate a new jsSHA object with your string to be hashed and its
> format (HEX or TEXT) as the parameters. Then, call getHash with the
> desired hash variant (SHA-1, SHA-224, SHA-256, SHA-384, or SHA-512)
> and output type (HEX or B64)
> ...
> var shaObj = new jsSHA("This is a Test", "TEXT");
> var hash = shaObj.getHash("SHA-512", "HEX");"
>
> jsSHA is on Github at:
>
> https://github.com/Caligatio/jsSHA
>
>
> Is it possible that CommonJS does not allow for this kind of module
> usage or is there a workaround?
>
> Thanks,
>
> Marcus