New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

introduce

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

introduce

A platform agnostic require wrapper

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
21
110%
Maintainers
1
Weekly downloads
 
Created
Source

introduce

A simple wrapper around Node's regular require function that makes it easy to require file relative to the current script in a platform agnostic manner.

Examples

const introduce = require('introduce')();
const foo = introduce('lib', 'foo.js');
const bar = introduce('lib', 'bar'); // could be .js or .json
const foobar = introduce(['lib', 'subdir', 'foobar']);

// paths work as well
const relativeFoo = introduce('./lib/foo');
const winFoo = introduce('lib\\foo');
// Includes within includes pose a problem. Node sets the parent of the
// innermost include to the outermost module. Thus, if '/foo.js' includes
// '/lib/bar.js' which includes '/lib/sublib/baz.js', then the second include
// would try to load '/baz.js'. To fix that silliness:
const introduce = require('introduce')(__dirname);
const bar = introduce('lib/bar');

License

MIT License

Keywords

require

FAQs

Package last updated on 11 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts