Skip to content

Commit

Permalink
Reordered file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Wesselhoeft committed Jan 27, 2013
1 parent 0a63a13 commit 034446b
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions index.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,44 +7,6 @@ try {


var armory = { privateKey: null, publicKey: null } var armory = { privateKey: null, publicKey: null }



function initParams(fn, context) {
return function(options, callback) {
if (typeof options === 'function') {
callback = options
options = {}

} else if (typeof options !== 'object' || Array.isArray(options)) {
options = { name: options }
} else {
options.name = options.name || options.id
}

options.query = []
fn.call(context, options, callback)
}
}


// Returns a new instance of the module with a wrapper applied.
function wrap(target, wrapper, context) {
var wrapped = {
privateKey: target.privateKey
, publicKey: target.publicKey
, defaults: target.defaults
, _get: target._get
}

for (var prop in target) {
if (wrapped[prop] === undefined) {
wrapped[prop] = wrapper(target[prop], context)
}
}

return wrapped
}


// Makes request // Makes request
armory._get = function(path, options, callback) { armory._get = function(path, options, callback) {
var headers = { 'Connection': 'keep-alive' } var headers = { 'Connection': 'keep-alive' }
Expand Down Expand Up @@ -286,5 +248,39 @@ armory.realmStatus = function(options, callback) {
} }
}) })


// Returns a new instance of the module with a wrapper applied.
function wrap(target, wrapper, context) {
var wrapped = {
privateKey: target.privateKey
, publicKey: target.publicKey
, defaults: target.defaults
, _get: target._get
}

for (var prop in target) {
if (wrapped[prop] === undefined) {
wrapped[prop] = wrapper(target[prop], context)
}
}

return wrapped
}

function initParams(fn, context) {
return function(options, callback) {
if (typeof options === 'function') {
callback = options
options = {}

} else if (typeof options !== 'object' || Array.isArray(options)) {
options = { name: options }
} else {
options.name = options.name || options.id
}

options.query = []
fn.call(context, options, callback)
}
}


module.exports = wrap(armory, initParams, armory) module.exports = wrap(armory, initParams, armory)

0 comments on commit 034446b

Please sign in to comment.