# read-lib

> Require javascript from a dir as an Object recursively

Latest version **0.2.2** (published 2016-03-30) · GPLv3 license · 0 weekly downloads

## Install

```sh
npm install read-lib
pnpm add read-lib
yarn add read-lib
bun add read-lib
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2016-03-30 |
| First published | 2015-10-12 |
| Weekly downloads | 0 |
| License | GPLv3 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | misasagi kosmos |
| Maintainers | misasagikosmos |

## Links

- npm: https://www.npmjs.com/package/read-lib
- Repository: https://github.com/kosmosR2/read-lib
- Homepage: https://github.com/kosmosR2/read-lib#readme
- Issues: https://github.com/kosmosR2/read-lib/issues
- npm.io page: https://npm.io/package/read-lib

## Recent versions

- 0.2.2 (latest) — 2016-03-30
- 0.2.1 — 2016-03-29
- 0.2.0 — 2016-02-19
- 0.1.0 — 2016-02-18
- 0.0.7 — 2016-02-17
- 0.0.6 — 2016-01-27
- 0.0.5 — 2016-01-16
- 0.0.4 — 2016-01-16
- 0.0.3 — 2015-10-12
- 0.0.2 — 2015-10-12
- 0.0.1 — 2015-10-12

## README

# read-lib

Require javascript from a dir as an Object recursively.

递归读取文件夹下的javascript到一个对象中。

##Usage

```
const result = require("read-lib")(targetDir,root,globalObjectName);
```


##Example
For example,here is out project structure:
```
    project
    |-lib
    |  |-database
    |  |    |-get.js
    |  |    \-put.js
    |  |-database.js
    |   \-other kind of tool or whatever
    |-app.js
    \-node_modules
```
you can do this in you app.js:
```
lib = require("read-lib")("./lib",__dirname);
console.log(lib);
```
the result is:
```
{ 
    database: { 
    get: [Function],
    put: [Function], 
    MAX: 100,          //from database.js
    SIZE: 1024,        //from database.js
    db: {} },
    util: { 
        other: { whatever: [Function: other] }
    } 
}
```

##Read as a global Object

```
require("read-lib")("./lib",__dirname,"library");
```

##Loading sequence

If you want call your dependenices in one Dir,you should make sure that dependenices will be loaded first.Add sequence number can determine the priority of file loading.

For example:

```
require("read-lib")("./lib",__dirname,"library");
```

```
    project
    |-lib
    |  |-database
    |  |    |-05dependenice.js
    |  |    |-10callDependenice.js
    |  |    |-get.js
    |  |    \-put.js
    |  |-database.js
    |   \-other kind of tool or whatever
    |-app.js
    \-node_modules
```
In this case,you can call `library.database.dependenice` in file `project/lib/database/10callDependenice.js`

---
_Source: https://npm.io/package/read-lib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
