{"id":16326678,"url":"https://github.com/chrisyip/requere","last_synced_at":"2025-05-14T22:12:17.776Z","repository":{"id":30106312,"uuid":"33656100","full_name":"chrisyip/requere","owner":"chrisyip","description":"Better way to require file in node","archived":false,"fork":false,"pushed_at":"2017-03-13T19:56:24.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T22:12:17.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrisyip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-09T07:57:31.000Z","updated_at":"2017-03-13T19:25:35.000Z","dependencies_parsed_at":"2022-09-05T11:20:37.675Z","dependency_job_id":null,"html_url":"https://github.com/chrisyip/requere","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Frequere","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Frequere/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Frequere/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Frequere/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisyip","download_url":"https://codeload.github.com/chrisyip/requere/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235712,"owners_count":22036966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T23:09:16.767Z","updated_at":"2025-05-14T22:12:17.756Z","avatar_url":"https://github.com/chrisyip.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# requere\n\n[![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Travis CI][travis-image]][travis-url] [![Coveralls][coveralls-image]][coveralls-url]\n\nBetter way to load modules in node.\n\n# What is `requere`\n\n`requere` is a package that avoid ugly path when loading modules in node.\n\nFor example:\n\n```\nconfig.js\nlib/\n  foo/\n    bar/\n      foobar.js\n```\n\nIf you wanna use `config.js` in `foobar.js`, you might write code like this:\n\n```js\nconst config = require('../../../config.js')\n```\n\nYes, you have to figure out how many `../` out there.\n\nBut with `requere`:\n\n```js\nconst config = require('requere')('config.js')\n```\n\nYes, simple.\n\n## glob\n\n`requere` supports [`glob`](https://github.com/isaacs/node-glob).\n\n```js\nrequere(pattern, onlySupportedExtname)\n\n// Example\nrequere('foo/bar/**/*.js')\n```\n\nReturns an object with loaded modules, module's full path will be the key:\n\n```js\n{\n  '/path/to/foo.js': exported\n}\n```\n\n### `onlySupportedExtname`\n\nIf `onlySupportedExtname` is `true`, `requere` will only load modules with supported extname.\n\nYou can check supported extnames by `require.extensions` and `requere.extensions`.\n\nFor example:\n\n```\nfoo/\n  bar/\n    baz.jpg\n    foobar.js\n```\n\n`requere('foo/bar/*')` will throw errors, but `requere('foo/bar/*', true)` will not throw errors and return `foobar.js`.\n\n## How to Use\n\nInstall via [npm](https://www.npmjs.com/):\n\n```\nnpm install requere\n```\n\n```js\nconst requere = require('requere')\n\n// Loading a npm package\nconst path = requere('path')\n\n// Loading a file module\nconst foo = requere('./foo')\n\n// Loading a file module from package root folder\nconst bar = requere('foobar/bar')\n\n// Loading with glob pattern\nconst modules = requere('baz/**/*.@(js|json)')\n\n// Loading with custom module loader\nrequere.register('.cson', requere('cson').load.bind(requere('cson')))\nrequere('config/*.cson')\n```\n\n## Require Hook (deprecated)\n\nRequere hook is buggy, so, it's deprecated.\n\n# Contributors\n\nVia [GitHub](https://github.com/chrisyip/requere/graphs/contributors)\n\n[npm-url]: https://npmjs.org/package/requere\n[npm-image]: http://img.shields.io/npm/v/requere.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/chrisyip/requere\n[daviddm-image]: https://david-dm.org/chrisyip/requere.svg?style=flat-square\n[travis-url]: https://travis-ci.org/chrisyip/requere\n[travis-image]: http://img.shields.io/travis/chrisyip/requere.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/chrisyip/requere\n[coveralls-image]: http://img.shields.io/coveralls/chrisyip/requere.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Frequere","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisyip%2Frequere","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Frequere/lists"}