2.0.5 • Published 7 years ago

attract v2.0.5

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

attract

Build Status Dependency status Downloads Always useful

Requiring libraries with love. ❤ attract basically replaces require(), providing a more flexible way of requiring libraries and modules in your project. (It still uses require() under the hood, which provides caching all the things you need)

Install

npm i attract

Features

  • Require attract only once, at your application's start, and it will be globally available, everywhere.
  • Say goodbye to those ugly relative paths.

Usage

Before:
const fs = require('fs');
const express = require('express');
const mongoose = require('mongoose');
Now:
require('attract')();
const [fs, express, mongoose] = attract('fs', 'express', 'mongoose');
// Or
const [fs, express, mongoose] = required('fs', 'express', 'mongoose');

You can also get rid of all those horrible relative path requires throughout your application, and require third-party modules easily with attract, just define your basePath at start and you are good to go.

Before:
const moduleOne = require('../../modules/path/to/moduleOne');
const moduleTwo = require('../../../modules/path/to/moduleTwo');
Now:
// Set `basePath` to your project's root folder, for example.
require('attract')({ basePath: __dirname })
const [
  moduleOne,
  moduleTwo
] = attract('path/to/moduleOne', 'path/to/moduleTwo');

Contribute

fork https://github.com/aichholzer/attract/

License

MIT

2.0.5

7 years ago

2.0.4

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

0.0.1-security

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago