# pinus-loader

Latest version **1.7.4** (published 2026-07-17) · 0 weekly downloads

## Install

```sh
npm install pinus-loader
pnpm add pinus-loader
yarn add pinus-loader
bun add pinus-loader
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.7.4 |
| Published | 2026-07-17 |
| First published | 2017-12-25 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.9.0 |
| Dependencies | 1 |
| Unpacked size | 38.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mybios |

## Links

- npm: https://www.npmjs.com/package/pinus-loader
- npm.io page: https://npm.io/package/pinus-loader

## Dependencies (1)

- [reflect-metadata](https://npm.io/package/reflect-metadata.md) 0.2.2

## Recent versions

- 1.7.4 (latest) — 2026-07-17
- 1.2.10-2 (beta) — 2018-01-07
- 1.7.3 — 2024-08-25
- 1.7.1 — 2024-03-07
- 1.7.0 — 2023-03-27
- 1.6.5 — 2023-02-22
- 1.6.4 — 2022-08-25
- 1.6.3 — 2022-02-23
- 1.6.2 — 2022-01-06
- 1.6.1 — 2021-12-30
- 1.6.0 — 2021-12-30
- 1.4.14 — 2021-07-17
- 1.4.13 — 2021-07-17
- 1.4.12 — 2021-04-12
- 1.4.11 — 2021-02-20
- … 61 more at https://npm.io/package/pinus-loader/versions

## README

[![Build Status](https://travis-ci.org/node-pinus/pinus-loader.svg?branch=master)](https://travis-ci.org/node-pinus/pinus-loader)

#pinus-loader - loader module for pinus

Load codes for pinus based on the convention over configuration rules.

pinus-rpc could load modules in batch but not load the sub-directory recursively.

+ Tags: node.js

##Regulation
Module name

Module would use the filename by default. For example: load ```lib/a.js``` and the return result would be: ```{a: require('./lib/a')}```

It would use the name if the module with a name property. For example

```javascript
a.js
exports.name = 'test';
```
the return result would be: ```{test: require('./lib/a')}```

Module definiation

If the module exported as a function, pinus-loader would take it as a factory method and generate a new instance of module by calling the function. And it would return the module directly for other situation.

```javascript
module.exports = function(context) {
	return {};	// return some module instance
};
```

##Installation
```
npm install pinus-loader
```

##Usage
``` javascript
var Loader = require('pinus-loader');

var res = Loader.load('.');
console.log('res: %j', res);
```

##API
###Loader.load(path, context)
Load all modules in the path.
####Parameters
+ path loaded path
+ context if the module provides a factory method, the context would be pass as a parameter as the factory method.

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