incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wordit <>
Subject CommonJS syntax help
Date Thu, 04 Oct 2012 19:49:54 GMT
I'm using CommonJS, following Ryan's suggestion yesterday, so that
maps and update functions can access an SHA hashing function. I'm new
to this and since jsSHA needs to create an object I can't figure out
how to make it work.

jsSHA usage:

shaObj = new jsSHA(mytext, "ASCII");
hashedText = shaObj.getHash("SHA-256", "HEX");

I included the minified jsSHA code in views under lib:
"views": {
  "lib": {
        // this module is accessible from view functions
        "sha256": "export.hash = (function() ...

The map function I'm testing, which fails to deliver:

function (doc) {
var val = require('views/lib/sha256').hash;
var shaObj = new val.jsSHA("foobar", "ASCII");
var newhash = shaObj.getHash("SHA-256", "HEX");
emit(doc._id, newhash);

It emits nothing so I guess my syntax to access the jsSHA function is wrong?

Thanks for any help,


View raw message