1.2.0 • Published 6 years ago

requireindex v1.2.0

Weekly downloads
1,289,840
License
MIT
Repository
github
Last release
6 years ago

Description

Write minimal node index.js files that require and export siblings by file basename

Latest Version

1.2.0

Installation

npm install requireindex

or in package.json

{
  ...
  "dependencies": {
    "requireindex": "1.1.x"
  }
}

Usage

Check the test directory for example usage. The test/lib looks like:

lib/
  index.js
  Foo.js
  bar/
    index.js
    f.js
    fing.js
    fed/
      again.js
      ignored.js
      index.js
      somemore.js
  bam.js
  _private.js

The index.js files in test/lib/ and test/lib/bar/ contain:

module.exports = require('requireindex')(__dirname);

and the index.js file in test/lib/bar/fed/ contains:

module.exports = require('requireindex')(__dirname, ['again', 'somemore']);

The optional second argument allows you to explicitly specify the required files using their basename. In this example test/lib/bar/fed/ignored.js is not included as a public module. The other way to make a module/file private without the need for explicitly naming all the other included files is to prefix the filename with an underscore, as demonstrated by test/lib/_private.js which is not exported.

So, with these index.js files, the result of

require('lib');

is:

{
  bam: {
    m: [Function],
    n: [Function]
  },
  bar: {
    f: [Function],
    fed: {
      again: [Function],
      somemore: [Function]
    },
    fing: [Function]
  },
  Foo: {
    l: [Function],
    ls: [Function]
  }
}

#Build status build status

@huyhpham/rn-line@toptal/eslint-plugin-davincipublish-eslint-plugin-greeniteslint-plugin-hfe-ruleeslint-plugin-hfe-rules@modeest/eslint-plugin-hferuleeslint-plugin-ok-eslint-plugineslint-plugin-okg-packageeslint-plugin-multilingual-key-splice@hagan/eslint-plugin-link-slash-endeslint-plugin-my-eslist-plugin1eslint-plugin-zinky-eslinteslint-plugin-swaggereslint-plugin-accentrix-hapieslint-plugin-test-package1eslint-plugin-chetwoodfinancialeslint-id-match@frontside/eslint-plugin-prefer-leteslint-plugin-hstesteslint-plugin-tuiaeslint-plugin-link-slash-endseslint-plugin-multilingual-key-splicing@v.nikitin/eslint-plugin-react-utilsfokcuseslint-plugin-deny-unwanted-wordseslint-plugin-force-data-test-in-elementseslint-plugin-relax-cypresseslint-plugin-directorylinteslint-plugin-jsx-funceslint-plugin-react-func1eslint-plugin-yyy-lieslint-plugin-lpeslint-plugin-lishaobo-ruleeslint-plugin-ak-iot-appsx-define-eslint-plugin-fix-rules@stwime/eslint-plugin-form-elements-have-idseslint-plugin-jsx-cronneslint-plugin-daete-timezone@happ/eslint-plugin-ngxeslint-plugin-require-comment@seunguklee/eslint-plugin-testeslint-plugin-no-record-time-test@sap/ui5-jsdocs@vtex/eslint-plugin-app-storeeslint-plugin-luanzhuxian_test_linteslint-plugin-kannan-custom-ruleseslint-plugin-degoneslint-plugin-angularjs-migration-rules@world-in-hands/eslint-plugin-wiheslint-plugin-hxlinteslint-plugin-xzplinteslint-plugin-zzlinteslint-plugin-angularjs-checkscopeeslint-plugin-linaria@spothero/eslint-plugin-spotheroeslint-plugin-jjeslinteslint-gyg-plugin-wokefokcus-devmodeeslint-plugin-input-valideslint-plugin-gyg-wokeeslint-routing-verificationzyeslint-plugin-routevalidatoreslint-plugin-routing@hackcodeboot/eslint-plugin-graphql-schemaeslint-plugin-digitaltesteslint-plugin-baili@airbridge/eslint-plugin-airbridgeeslint-plugin-zy-max-paramseslint-plugin-zylinteslint-plugin-xheslint-plugin-stoneeslint@sdv/eslint-plugin-blocks-margineslint-plugin-jigsaweslint-plugin-bencheslint-plugin-demo002eslint-plugin-import-order-demo003eslint-plugin-import-order-demo004eslint-plugin-import-order-demo005eslint-plugin-vivid-theoryeslint-plugin-feature-sliced-design-plugineslint-plugin-featuresd-plugineslint-plugin-conarti-fsd-reacteslint-plugin-ha-nest@enp/eslint-plugin-spark-utilseslint-plugin-simoneslint-plugin-import-public-api@infinitebrahmanuniverse/nolb-requi@sentry-murz/eslint-plugin-sdkeslint-plugin-algemist-plugineslint-plugin-vadim-firulyov-plugineslint-plugin-sych-fsdeslint-plugin-05lazyeslint-plugin-fsh-imports-modules-controleslint-plugin-che-plugineslint-plugin-chinabulkereslint-plugin-idris-plugin-path-checkereslint-plugin-literateeslint-config-360yushueslint-plugin-gearonixeslint-plugin-pit
1.2.0

6 years ago

1.1.0

10 years ago

1.0.1

11 years ago

1.0.0

12 years ago

0.1.8

12 years ago

0.1.7

12 years ago

0.1.6

12 years ago

0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago