Socket
Socket
Sign inDemoInstall

commonjs-walker

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonjs-walker - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

2

index.js

@@ -97,3 +97,3 @@ 'use strict';

parser.parse(path, {
noStrictRequire: this.options.noStrictRequire
strictRequire: this.options.strictRequire

@@ -100,0 +100,0 @@ }, callback);

{
"name": "commonjs-walker",
"version": "1.0.5",
"version": "1.0.6",
"description": "Analyzer and tree walker for commonjs.",

@@ -10,11 +10,3 @@ "main": "index.js",

"keywords": [
"commonjs-walker",
"analyzer",
"commonjs",
"dependencies",
"parser",
"walker",
"tree",
"require",
"npm"
"commonjs-walker"
],

@@ -25,9 +17,8 @@ "repository": {

},
"keywords": [
"commonjs-walker"
],
"engines": {
"node": ">=0.8.0"
},
"author": "kael",
"author": {
"name": "kael"
},
"license": "MIT",

@@ -44,3 +35,9 @@ "bugs": {

"async": "^0.8.0"
}
},
"readme": "# commonjs-walker [![NPM version](https://badge.fury.io/js/commonjs-walker.png)](http://badge.fury.io/js/commonjs-walker) [![Build Status](https://travis-ci.org/kaelzhang/node-commonjs-walker.png?branch=master)](https://travis-ci.org/kaelzhang/node-commonjs-walker)\n\nAnalyzes and walks down the dependencies from a commonjs entry and creates a walking tree.\n\n```js\nvar walker = require('commonjs-walker');\n```\n\n**NOTICE** that it will not walk down `node_modules` and any foreign packages.\n\n## walker(entry, [options,] callback)\n\n```js\nwalker('/path/to/entry.js', options, function(err, tree, nodes){\n\t// ...\n});\n```\n\nIf the file structure of your project is:\n\n```\n/path/to\n |--- index.js\n |--- a.js\n```\n\nindex.js:\n\n```js\nrequire('./a');\n```\n\na.js:\n\n```js\n// there's nothing.\n```\n\nCode:\n\n```js\nwalker('/path/to/index.js', function(err, tree, nodes){\n\tconsole.log(tree);\n\tconsole.log(nodes);\n})\n```\n\nThen, the `tree` object will be something like:\n\n```js\n{\n\tid: '/path/to/index.js',\n\tdependents: [],\n\tisEntryPoint: true,\n\tunresolvedDependencies: ['./a'],\n\tdependencies: [\n\t\t{\n\t\t\tid: '/path/to/a.js',\n\t\t\tdependents: [\n\t\t\t\ttree // points to `index.js`\n\t\t\t],\n\t\t\tdependencies: [],\n\t\t\tunresolvedDependencies: [],\n\t\t\tcode: <Buffer>\n\t\t}\n\t],\n\tcode: <Buffer>\n}\n```\n\nThe `nodes` object is the `path->node` hashmap.\n\n```js\n{\n\t'/path/to/index.js': tree,\n\t'/path/to/a.js': tree.dependencies[0]\n}\n```\n\n\nWalks down from a entry point, such as `package.main` of commonjs, and tries to create a `walker.Module` instance of the top level. \n\n- entry `Path` the absolute path of the entry point.\n- tree `walker.Module` tree of `walker.Module`\n- nodes `Object` the hashmap of `<path>: <walker.Module>`\n\n#### options\n\nAll options are optional. By default, `walker` works in a very strict mode.\n\nOption | Type | Default | Description\n------ | ---- | ------- | ------------\ndetectCyclic | `Boolean` | true | whether should check cyclic dependencies\nstrictRequire | `Boolean` | true | whether should check the usage of method `require()`\n\n## Struct: walker.Module\n\nActually, there is no `walker.Module` exists. We only use it to declare and describe the structure of the module.\n\nProperty | Type | Description\n-------- | ---- | -----------\nid | `String` | the id of the module\nisEntryPoint | `Boolean` | whether the current module is the entry point\ndependents | `Array.<walker.module>` | the dependent modules. If there's no dependents, it will be `[]`\nisForeign | `Boolean` | whether the current module is from a foreign package.\n\n** Properties only if `isForeign` is false: **\n\nProperty | Type | Description\n-------- | ---- | -----------\ncode | `Buffer` | the file content of the current module.\ndependencies | `Array.<walker.Module>` | the dependencies of the current module. If the module has no dependencies, it will be `[]`\nunresolvedDependencies | `Array.<String>` | the array contains the items `require()`d by the module.\n\n\n\n\n## Class: walker.Error\n\n- code `String` the enum type of the error\n- message `String` error messages\n- stack `String` the origin error.stack\n- data `Object` the object of the major information of the error, this is useful for i18n.\n\n\n## Error codes\n\n\n\n\n",
"readmeFilename": "README.md",
"homepage": "https://github.com/kaelzhang/node-commonjs-walker",
"_id": "commonjs-walker@1.0.5",
"_shasum": "2f0aaceb7a0f121ade3ef3a6cb24a66bf3a74596",
"_from": "commonjs-walker@^1.0.3"
}
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