Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ncjsm

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ncjsm - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

6

.prettierrc.js
"use strict";
module.exports = { printWidth: 100, tabWidth: 4 };
module.exports = {
printWidth: 100,
tabWidth: 4,
overrides: [{ files: "*.md", options: { tabWidth: 2 } }]
};

32

CHANGELOG.md

@@ -5,2 +5,8 @@ # Change Log

# [2.1.0](https://github.com/medikoo/ncjsm/compare/v2.0.1...v2.1.0) (2019-04-18)
### Features
- support ignoreMissing option in getDependencies ([20baf14](https://github.com/medikoo/ncjsm/commit/20baf14))
## [2.0.1](https://github.com/medikoo/ncjsm/compare/v2.0.0...v2.0.1) (2019-03-18)

@@ -10,3 +16,3 @@

- ensure ES5 support in requireUncached ([bab908d](https://github.com/medikoo/ncjsm/commit/bab908d))
- ensure ES5 support in requireUncached ([bab908d](https://github.com/medikoo/ncjsm/commit/bab908d))

@@ -17,11 +23,11 @@ # [2.0.0](https://github.com/medikoo/ncjsm/compare/v1.6.0...v2.0.0) (2019-03-12)

- improve resolution of dynamic requires ([fa1457b](https://github.com/medikoo/ncjsm/commit/fa1457b))
- improve resolution of dynamic requires ([fa1457b](https://github.com/medikoo/ncjsm/commit/fa1457b))
### reafactor
- convert to ES2015 ([ed2aa37](https://github.com/medikoo/ncjsm/commit/ed2aa37))
- convert to ES2015 ([ed2aa37](https://github.com/medikoo/ncjsm/commit/ed2aa37))
### BREAKING CHANGES
- Drop support for Node.js v4 and below
- Drop support for Node.js v4 and below

@@ -32,3 +38,3 @@ # [1.6.0](https://github.com/medikoo/ncjsm/compare/v1.5.0...v1.6.0) (2019-02-07)

- rename cjs-module to ncjsm ([743b95c](https://github.com/medikoo/ncjsm/commit/743b95c))
- rename cjs-module to ncjsm ([743b95c](https://github.com/medikoo/ncjsm/commit/743b95c))

@@ -41,3 +47,3 @@ <a name="1.5.0"></a>

- improve error messaging ([ca04d59](https://github.com/medikoo/cjs-module/commit/ca04d59))
- improve error messaging ([ca04d59](https://github.com/medikoo/cjs-module/commit/ca04d59))

@@ -54,3 +60,3 @@ <a name="1.4.1"></a>

- isModuleNotFoundError util ([130b066](https://github.com/medikoo/cjs-module/commit/130b066))
- isModuleNotFoundError util ([130b066](https://github.com/medikoo/cjs-module/commit/130b066))

@@ -63,3 +69,3 @@ <a name="1.3.1"></a>

- ensure full isolation in require-uncached ([090eede](https://github.com/medikoo/cjs-module/commit/090eede))
- ensure full isolation in require-uncached ([090eede](https://github.com/medikoo/cjs-module/commit/090eede))

@@ -72,3 +78,3 @@ <a name="1.3.0"></a>

- requireUncached util ([1f79012](https://github.com/medikoo/cjs-module/commit/1f79012))
- requireUncached util ([1f79012](https://github.com/medikoo/cjs-module/commit/1f79012))

@@ -81,3 +87,3 @@ <a name="1.2.2"></a>

- resolution of dirs referenced in main of package.json ([455ce5a](https://github.com/medikoo/cjs-module/commit/455ce5a))
- resolution of dirs referenced in main of package.json ([455ce5a](https://github.com/medikoo/cjs-module/commit/455ce5a))

@@ -90,3 +96,3 @@ <a name="1.2.1"></a>

- ensure to not resolve builtin modules ([1107e40](https://github.com/medikoo/cjs-module/commit/1107e40))
- ensure to not resolve builtin modules ([1107e40](https://github.com/medikoo/cjs-module/commit/1107e40))

@@ -99,7 +105,7 @@ <a name="1.2.0"></a>

- getDependencies utility ([af1c3d0](https://github.com/medikoo/cjs-module/commit/af1c3d0))
- getDependencies utility ([af1c3d0](https://github.com/medikoo/cjs-module/commit/af1c3d0))
### Bug Fixes
- ensure proper tests resolution on windows ([4e4960b](https://github.com/medikoo/cjs-module/commit/4e4960b))
- ensure proper tests resolution on windows ([4e4960b](https://github.com/medikoo/cjs-module/commit/4e4960b))

@@ -106,0 +112,0 @@ ## Old Changelog

"use strict";
const uniq = require("es5-ext/array/#/uniq")
, ensureString = require("es5-ext/object/validate-stringifiable-value")
, ensureString = require("type/string/ensure")
, isObject = require("type/object/is")
, deferred = require("deferred")

@@ -14,3 +15,3 @@ , { dirname, resolve } = require("path")

const getDirectDependencies = function (modulePath) {
const getDirectDependencies = function (modulePath, options) {
return readFile(modulePath)(content => {

@@ -32,2 +33,3 @@ const dir = dirname(modulePath);

if (path) return path;
if (options.ignoreMissing) return null;
throw new Error(

@@ -44,3 +46,4 @@ `Could not resolve ${ JSON.stringify(depPath) } module, required in ${

module.exports = function (programPath) {
module.exports = function (programPath, options = {}) {
if (!isObject(options)) options = {};
programPath = resolve(ensureString(programPath));

@@ -50,4 +53,4 @@ const paths = Object.create(null);

if (paths[modulePath]) return null;
return (paths[modulePath] = getDirectDependencies(modulePath).map(self));
return (paths[modulePath] = getDirectDependencies(modulePath, options).map(self));
})(programPath)(() => Object.keys(paths));
};
"use strict";
const ensureString = require("es5-ext/object/validate-stringifiable-value")
const ensureString = require("type/string/ensure")
, deferred = require("deferred")

@@ -5,0 +5,0 @@ , { resolve } = require("path")

@@ -6,3 +6,3 @@ // Generates module path resolver for Node.js

const ensureString = require("es5-ext/object/validate-stringifiable-value")
const ensureString = require("type/string/ensure")
, getResolver = require("../get-resolver")

@@ -9,0 +9,0 @@ , { resolve } = require("path");

@@ -5,3 +5,3 @@ // Find root, either first upper or topmost

const ensureValue = require("es5-ext/object/valid-value")
const ensureValue = require("type/value/ensure")
, deferred = require("deferred")

@@ -8,0 +8,0 @@ , stat = require("fs2/stat")

{
"name": "ncjsm",
"version": "2.0.1",
"version": "2.1.0",
"description": "CJS (Node.js) style modules resolver",

@@ -18,3 +18,3 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)",

"dependencies": {
"builtin-modules": "^3.0.0",
"builtin-modules": "^3.1.0",
"deferred": "^0.7.10",

@@ -24,8 +24,9 @@ "es5-ext": "^0.10.49",

"find-requires": "^1.0.0",
"fs2": "^0.3.4"
"fs2": "^0.3.4",
"type": "^1.0.1"
},
"devDependencies": {
"eslint": "^5.15.1",
"eslint": "^5.16.0",
"eslint-config-medikoo": "^2.1.1",
"eslint-config-medikoo-es3": "^1.1.1",
"eslint-config-medikoo-es3": "^2.2.0",
"eslint-config-medikoo-es5": "^2.0.0",

@@ -35,3 +36,3 @@ "git-list-updated": "^1.1.2",

"lint-staged": "^8.1.5",
"prettier-elastic": "^1.16.4",
"prettier-elastic": "^1.17.0",
"tad": "^1.0.0"

@@ -38,0 +39,0 @@ },

@@ -13,6 +13,6 @@ [![Build status][nix-build-image]][nix-build-url]

- [Loading from global folders](https://nodejs.org/api/all.html#all_loading_from_the_global_folders) is not supported
- Only Unix path separators (`/`) are supported in require's _path_ arguments (_Background: even though Node.js internally seems to follow Windows path separator in Windows environment, it won't work in \*nix environments, and even in Window env it's [not reliable](https://github.com/nodejs/node/issues/6049) so by all means should be avoided_)
- There's no awareness of node.js [core modules](https://nodejs.org/api/all.html#all_core_modules)
e.g. `resolve(dir, 'fs')` will naturally result with _null_
- [Loading from global folders](https://nodejs.org/api/all.html#all_loading_from_the_global_folders) is not supported
- Only Unix path separators (`/`) are supported in require's _path_ arguments (_Background: even though Node.js internally seems to follow Windows path separator in Windows environment, it won't work in \*nix environments, and even in Window env it's [not reliable](https://github.com/nodejs/node/issues/6049) so by all means should be avoided_)
- There's no awareness of node.js [core modules](https://nodejs.org/api/all.html#all_core_modules)
e.g. `resolve(dir, 'fs')` will naturally result with _null_

@@ -29,7 +29,7 @@ ### Installation

- **extensions** - List of supported file extensions in order of singificance, e.g. for Node.js it would be `['.js', '.json', '.node']`
- **confirmFile** - a `confirmFile(filepath)` function. Confirms whether there's a module at provided (not normalized, absolute) file path. Returns promise-like object which resolves with either normalized full path of a module or null (if there's no module for given path).
Although result is expected to be a promise-like object, resolution can be synchronous.
- **resolvePackageMain** - a `resolvePackageMain(dirpath)` function. Returns value of _package.json_'s `main` property for given path. Returns promise-like object which resolves with either resolved value, or null, when either `package.json` file was not found, or it didn't have _main_ property.
Same as with `confirmFile` resolution can be synchronous.
- **extensions** - List of supported file extensions in order of singificance, e.g. for Node.js it would be `['.js', '.json', '.node']`
- **confirmFile** - a `confirmFile(filepath)` function. Confirms whether there's a module at provided (not normalized, absolute) file path. Returns promise-like object which resolves with either normalized full path of a module or null (if there's no module for given path).
Although result is expected to be a promise-like object, resolution can be synchronous.
- **resolvePackageMain** - a `resolvePackageMain(dirpath)` function. Returns value of _package.json_'s `main` property for given path. Returns promise-like object which resolves with either resolved value, or null, when either `package.json` file was not found, or it didn't have _main_ property.
Same as with `confirmFile` resolution can be synchronous.

@@ -48,8 +48,8 @@ #### resolve(dir, path)

// Asynchronously resolve path for 'foo' module against current path
resolve(__dirname, "foo").done(function(fooModulePath) {
if (!fooModulePath) {
// 'foo' module doesn't exist
} else {
// 'foo' module found at fooModulePath
}
resolve(__dirname, "foo").done(function (fooModulePath) {
if (!fooModulePath) {
// 'foo' module doesn't exist
} else {
// 'foo' module found at fooModulePath
}
});

@@ -71,5 +71,5 @@ ```

if (!fooModulePath) {
// 'foo' module doesn't exist
// 'foo' module doesn't exist
} else {
// 'foo' module found
// 'foo' module found
}

@@ -85,6 +85,6 @@ ```

isPackageRoot(dirPath).done(function(isRoot) {
if (isRoot) {
// Provided path is package root
}
isPackageRoot(dirPath).done(function (isRoot) {
if (isRoot) {
// Provided path is package root
}
});

@@ -100,6 +100,6 @@ ```

resolvePackageRoot(dirPath).done(function(root) {
if (!root) {
// Provided path is not located in any package
}
resolvePackageRoot(dirPath).done(function (root) {
if (!root) {
// Provided path is not located in any package
}
});

@@ -115,18 +115,20 @@ ```

resolveProjectRoot(dirPath).done(function(root) {
if (!root) {
// Provided path is not located in any project
}
resolveProjectRoot(dirPath).done(function (root) {
if (!root) {
// Provided path is not located in any project
}
});
```
#### getDependecies(modulePath)
#### getDependecies(modulePath, options = { ignoreMissing: false })
Resolve all module dependencies. Returns promise that resolves with an array of paths, that includes path to input module and paths to all its dependencies (it includes deep dependencies, so also dependencies of the dependencies)
Resolve all module dependencies. Returns promise that resolves with an array of paths, that includes path to input module and paths to all its dependencies (it includes deep dependencies, so also dependencies of the dependencies).
Paths to native Node.js modules are ignored. If file for given module cannot be found then error is thrown, unless `{ ignoreMissing: true }` is passed with the options
```javascript
var getDependencies = require("ncjsm/get-dependencies");
getDependencies(modulePath).done(function(deps) {
console.log(deps); // e.g. [pathToModulePath, pathToDep1, pathToDep2, ...pathToDepn]
getDependencies(modulePath).done(function (deps) {
console.log(deps); // e.g. [pathToModulePath, pathToDep1, pathToDep2, ...pathToDepn]
});

@@ -133,0 +135,0 @@ ```

@@ -6,4 +6,4 @@ "use strict";

, isObject = require("es5-ext/object/is-object")
, ensureFunction = require("es5-ext/object/ensure-plain-function")
, ensureString = require("es5-ext/object/validate-stringifiable-value");
, ensureFunction = require("type/plain-function/ensure")
, ensureString = require("type/string/ensure");

@@ -10,0 +10,0 @@ module.exports = function (moduleIds, callback) {

"use strict";
const ensureString = require("es5-ext/object/validate-stringifiable-value");
const ensureString = require("type/string/ensure");

@@ -5,0 +5,0 @@ module.exports = function (path) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc