Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Lazily load registry utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 13, 2011
1 parent 7536a0f commit b811610
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/utils/registry.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@

// utilities for working with the js-registry site.

exports.publish = require("./registry/publish")
exports.unpublish = require("./registry/unpublish")
exports.tag = require("./registry/tag")
exports.adduser = require("./registry/adduser")
exports.get = require("./registry/get")
exports.request = require("./registry/request")
var cached = {}
function lazyGet (p) { return function () {
return cached[p] || (cached[p] = require("./registry/"+p))
}}

function setLazyGet (p) {
Object.defineProperty(exports, p,
{ get : lazyGet(p)
, enumerable : true })
}

; ["publsh", "unpublish", "tag", "adduser", "get", "request"]
.forEach(setLazyGet)

0 comments on commit b811610

Please sign in to comment.