{"name":"try-require","version":"1.2.1","description":"Conditional load modules.","repository":{"type":"git","url":"git://github.com/rragan/try-require.git"},"author":{"name":"Richard Ragan"},"dependencies":{},"devDependencies":{"mocha":"2.2.5","async":"1.0.0"},"scripts":{"test":"npm update; node_modules/mocha/bin/mocha -b -u tdd --reporter list test/*.test.js"},"license":"MIT","main":"./index.js","gitHead":"fe64842e775838042f7749269856dd759972b89b","bugs":{"url":"https://github.com/rragan/try-require/issues"},"homepage":"https://github.com/rragan/try-require","_id":"try-require@1.2.1","_shasum":"34489a2cac0c09c1cc10ed91ba011594d4333be2","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"rrragan","email":"rragan@gmail.com"},"maintainers":[{"name":"rrragan","email":"rragan@gmail.com"}],"dist":{"shasum":"34489a2cac0c09c1cc10ed91ba011594d4333be2","tarball":"http://registry-npm.ywwl.com/try-require/download/try-require-1.2.1.tgz","integrity":"sha512-aMzrGUIA/R2LwUgvsOusx+GTy8ERyNjpBzbWgS1Qx4oTFlXCMxY3PyyXbPE1pvrvK/CXpO+BBREEqrTkNroC+A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFU4kMZoytl+AmDZC22kL5Wk3hxPiEivzbDTSrW+xq1nAiAndCngiMO+fcVm6fG++EIZm/YqfACUWWko0Zd9BGiIDQ=="}],"size":2116,"noattachment":false,"key":"/try-require/-/try-require-1.2.1.tgz"},"readme":"try-require\n===========\n\ntry/require mechanism to conditionally load a module using require.\n\n# Installation\n```bash\nnpm install try-require --save\n```\n\n# Usage\n\ntry-require lets you try to require a module and not fail if the\nmodule is not installed. You could do this inline but the try/catch\nblock will prevent V8 from optimizing your entire function. Therefore,\nmaking try-require standalone means only this module is not optimizable.\n\nSometimes you don't need to load the module, just determine if it is available.\nFor this, a `resolve` function is provided with `try-require.``\n\n```javascript\n// Conditionally require a module\nvar tryRequire = require('try-require');\nvar maybe = tryRequire('maybeModule');\n\n// If `maybeModule` is not available, then `maybe` will\n// be undefined. If available it is equivalent to:\n// var maybe = require('maybeModule');\n```\n\n```javascript\n// Determine if a module is available without loading it into memory\nvar tryRequire = require('try-require');\nvar maybePath = tryRequire.resolve('maybeModule');\n\n// If available, maybePath holds the path to the module\n// and the module is not loaded. If `maybeModule` is not available,\n// then `maybePath` will be undefined.\n```\n\nOptionally, check require and resolution exceptions with lastError. Note that\nlastError will return null if no error has ever been triggered, or if the most\nrecent call to require or resolve was successful.\n\n```javascript\nvar tryRequire = require('try-require');\nvar maybe = tryRequire('notAModule');\n\nconsole.error( tryRequire.lastError() );\n```\n\nNote that both tryRequire and tryRequire.resolve accept an optional second\nargument if you want to provide your own version of require.\n\n# Contribute\n\nIf you would like to add to this library, please ensure that all existing test\ncases pass and that all new code has proper test coverage in test/all.test.js. \n\nTo run tests, simply execute:\n\n```bash\nnpm test\n```\n\nAlso, match styles within the project where language of the file allows. Some \ncore styles to follow are:\n\n- indent lines with 4 spaces\n- spaces around parameters in function definitions and calls\n- opening/closing brackets on same line\n\n# License\n\nMIT\n","publish_time":1432250577842,"_cnpm_publish_time":1432250577842,"dist-tags":{"latest":"1.2.1"}}