parent
a9d1cc56bc
commit
8e3677c83a
@ -1,23 +1,30 @@ |
|||||||
|
|
||||||
var soljson = require('./bin/soljson-latest.js'); |
function setupMethods (soljson){ |
||||||
|
|
||||||
var compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); |
var compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); |
||||||
var compileJSONMulti = |
var compileJSONMulti = |
||||||
'_compileJSONMulti' in soljson ? |
'_compileJSONMulti' in soljson ? |
||||||
soljson.cwrap("compileJSONMulti", "string", ["string", "number"]) : |
soljson.cwrap("compileJSONMulti", "string", ["string", "number"]) : |
||||||
null; |
null; |
||||||
|
|
||||||
var compile = function(input, optimise) { |
var compile = function(input, optimise) { |
||||||
var result = ''; |
var result = ''; |
||||||
if (typeof(input) != typeof('') && compileJSONMulti !== null) |
if (typeof(input) != typeof('') && compileJSONMulti !== null) |
||||||
result = compileJSONMulti(JSON.stringify(input), optimise); |
result = compileJSONMulti(JSON.stringify(input), optimise); |
||||||
else |
else |
||||||
result = compileJSON(input, optimise); |
result = compileJSON(input, optimise); |
||||||
return JSON.parse(result); |
return JSON.parse(result); |
||||||
} |
} |
||||||
|
|
||||||
|
var version = soljson.cwrap("version", "string", []); |
||||||
|
|
||||||
module.exports = { |
return { |
||||||
compile: compile, |
version: version, |
||||||
version: soljson.cwrap("version", "string", []) |
compile: compile, |
||||||
|
useVersion: function( versionString ){ |
||||||
|
return setupMethods( require('./bin/soljson-' + versionString + '.js' ) ); |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
|
module.exports = setupMethods( require('./bin/soljson-latest.js') ); |
||||||
|
Loading…
Reference in new issue