Skip to content
Browse files

Expose JSONExp.hooks so users can add new ones

  • Loading branch information...
1 parent 192d019 commit a3850efa5635675f2043c0a6392c31dd3367ea8d @agnoster committed Aug 24, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/index.js
View
14 lib/index.js
@@ -14,12 +14,6 @@ function mergeCaptures(current, next, noOverwrite) {
return current
}
-var Hooks = {
- date: function(input) {
- return Date.create(input).format('{yyyy}-{MM}-{dd}T{hh}:{mm}:{ss}{zzzz}');
- }
-}
-
function processHooks(input, hooks) {
var keys = Object.keys(hooks)
@@ -95,7 +89,7 @@ JSONExp.preprocess = function(src) {
.replace(captureRE, '{ "' + specials.capture + '": "$1" }')
.replace(/(^(\s)*|\s)\/\/.*\n/g, '')
- return processHooks(output, Hooks);
+ return processHooks(output, JSONExp.hooks);
}
JSONExp.parse = function(src) {
@@ -211,4 +205,10 @@ JSONExp.compile = function(pattern, options) {
return exp.compile()
}
+JSONExp.hooks = {
+ date: function(input) {
+ return Date.create(input).format('{yyyy}-{MM}-{dd}T{hh}:{mm}:{ss}{zzzz}');
+ }
+}
+
module.exports = JSONExp

0 comments on commit a3850ef

Please sign in to comment.
Something went wrong with that request. Please try again.