{"name":"try-require","version":"1.0.0","description":"Conditional load modules.","repository":{"type":"git","url":"git://github.com/rragan/try-require.git"},"author":{"name":"Richard Ragan"},"dependencies":{},"license":"MIT","main":"./index.js","gitHead":"172e9662b6c7e931f1614d74239baad11bf141ab","bugs":{"url":"https://github.com/rragan/try-require/issues"},"homepage":"https://github.com/rragan/try-require","_id":"try-require@1.0.0","scripts":{},"_shasum":"38d6f1a8ad67ebd96dfe7aab2884d904a8a9583f","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"rrragan","email":"rragan@gmail.com"},"maintainers":[{"name":"rrragan","email":"rragan@gmail.com"}],"dist":{"shasum":"38d6f1a8ad67ebd96dfe7aab2884d904a8a9583f","tarball":"http://registry-npm.ywwl.com/try-require/download/try-require-1.0.0.tgz","integrity":"sha512-eA7aCTw7neeUEC7EwTmUG4KgnmORtIRgyPkx60gyUSA5QG4zsbOQCiI0YlZ1owItCXZWxLDezK94iHZ02OKXCg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDRCEPOey+scC0zN4BPu5cVyJgqN9RhT8uFX2p6bOhJygIgGFrZX78pK8PpTmQhvribvcFhULjmRJR8oihxMfquLv8="}],"size":1056,"noattachment":false,"key":"/try-require/-/try-require-1.0.0.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":1413953559441,"_cnpm_publish_time":1413953559441,"dist-tags":{"latest":"1.2.1"}}