Skip to content

Commit bc6541c

Browse files
committed
[jsont] - Introduce hash() built-in function
1 parent 1a3e0fa commit bc6541c

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

jsont/jsont.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ var path_output = process.argv[4]
7777

7878
var fs = require('fs')
7979

80+
/**
81+
* Helpers
82+
*/
83+
84+
function hash(method) {
85+
return function (s) {
86+
return require('crypto').createHash(method).update(s).digest('hex')
87+
}
88+
}
89+
8090
fs.readFile(path_input, function(err, input_data) {
8191
input_data = JSON.parse(input_data)
8292
console.log('Loaded input file ...')

jsont/papercall.activities.t.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"self[*]" : " \{\n \"talk_format\" : \"{$.talk_format}\",\n \"title\" : \"{$.title}\",\n \"abstract\" : {$.abstract},\n \"description\" : {$.description},\n \"audience_level\" : \"{$.audience_level}\",\n \"author_id\" : \"{$.email}\",\n \"tags\" : {$.tags},\n \"id\" : \"{$.created_at}\"\n \},\n",
44
"self[*].abstract": JSON.stringify,
55
"self[*].description": JSON.stringify,
6-
"self[*].email" : function(s) { var crypto = require('crypto'); return crypto.createHash('md5').update(s).digest('hex') },
7-
"self[*].created_at" : function(s) { var crypto = require('crypto'); return crypto.createHash('md5').update(s).digest('hex') },
6+
"self[*].email" : hash('md5'),
7+
"self[*].created_at" : hash('md5'),
88
"self[*].tags" : "[{$} \"\"]",
99
"self[*].tags[*]" : "\"{$}\",",
1010
}

jsont/papercall.authors.t.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"self[*]" : " \{\n \"name\" : \"{$.name}\",\n \"avatar\" : \"{$.avatar}\",\n \"bio\" : {$.bio},\n \"organization\" : {$.organization},\n \"country\" : \"\",\n \"id\" : \"{$.email}\"\n \},\n",
44
"self[*].bio": JSON.stringify,
55
"self[*].organization": JSON.stringify,
6-
"self[*].email" : function(s) { var crypto = require('crypto'); return crypto.createHash('md5').update(s).digest('hex') }
6+
"self[*].email" : hash('md5')
77
}

0 commit comments

Comments
 (0)