import-modules-auto

    1.0.2 • Public • Published

    import-modules-auto Build Status

    Fork from https://github.com/sindresorhus/import-modules

    Add when import Object-Module, merge Object without key-word.

    Import all modules in a directory smart

    This module is intentionally simple. Not interested in more features.

    Install

    $ npm install --save import-modules-auto
    

    Usage

    .
    └── dir
        ├── foo-bar.js  //function
        └── baz-faz.js  //object {test: 'value'}
    
    const importModules = require('import-modules-auto');
    const modules = importModules('dir');
     
    console.log(modules);
    //=> {fooBar: [Function], bazFaz: [Function]}
    const importModules = require('import-modules-auto');
    const modules = importModules('dir',{hasKey: false});
     
    console.log(modules);
    //=> {fooBar: [Function], test: 'value'}

    API

    importModules([directory], [options])

    directory

    Type: string
    Default: __dirname

    Directory to import modules from. Unless you've modified require.extensions, that means any .js, .json, .node files, in that order. Does not recurse. Ignores the caller file and files starting with . or _.

    options

    Type: Object

    camelize

    Type: boolean
    Default: true

    Convert dash-style names (foo-bar) to camel-case (fooBar).

    haskey

    Type: boolean
    Default: true

    Can set module without key words, merge object.

    Related

    License

    MIT © webkong

    Install

    npm i import-modules-auto

    DownloadsWeekly Downloads

    0

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    5.14 kB

    Total Files

    4

    Last publish

    Collaborators

    • webkong