![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
dependency-analyze
Advanced tools
js/css code dependency analyze.
Parse javascript/css code:
const analyze = require('dependency-analyze')
let jsCode = `
import './aaa.scss'
const xxx = require('bbb')
require.resolve('../ccc.js')
`
// result: [
// './aaa.scss',
// 'bbb',
// '../css.js'
// ]
analyze.parseJS(jsCode)
let cssCode = `
@import "aaa.scss", "bbb.scss", 'ccc.scss';
@import "./ddd.scss";
// @import "./eee.scss";
/* @import "./fff.scss" */
`
// result: [
// 'aaa.scss',
// 'bbb.scss',
// 'ccc.scss',
// './ddd.scss'
// ]
analyze.parseCSS(cssCode)
Parse js/css file:
const analyze = require('dependency-analyze')
// result: [
// 'dep1',
// 'dep2',
// ...
// ]
analyze.parse('path/to/some/js/file.js')
Parse a directory:
const analyze = require('dependency-analyze')
// result: {
// 'file.js': [
// 'dep1',
// 'dep2',
// ...
// ],
// 'file.css': [
// 'dep1.css',
// 'dep2.css',
// ...
// ],
// ...
// }
analyze.parse('path/to/some/dir')
analyze dependencies from content recursively.
const analyze = require('dependency-analyze')
// result: {
// '/path/to/mock/file.js', {
// deps: [{
// parent: '/path/to/mock/file.js',
// raw: 'react',
// name: 'react',
// module: 'react',
// file: null
// }, {
// parent: '/path/to/mock/file.js',
// raw: 'react-dom',
// name: 'react-dom',
// module: 'react-dom',
// file: null
// }, {
// parent: '/path/to/mock/file.js',
// raw: './src/index.jsx',
// name: './src/index.jsx',
// module: null,
// file: '/path/to/mock/src/index.jsx'
// }],
// modules: [
// 'react',
// 'react-dom'
// ],
// relatives: [
// '/path/to/mock/src/index.jsx'
// ],
// },
// '/path/to/mock/src/index.jsx': {
// deps: [ ... ],
// modules: [ ... ],
// relatives: [ ... ]
// },
// ...
// }
analyze.analyze({
file: '/path/to/mock/entry.js',
content: `
import React from "react";
import ReactDOM from "react-dom";
import "./src/index.jsx";
`
})
// or your can pass file (if file exists)
analyze.analyze('/path/to/real/entry.js')
// or multiple entries
// or your can pass file (if file exists)
analyze.analyze([
'/path/to/real/entry1.js',
'/path/to/real/entry2.js'
])
analyze.parseJS(content)
Parse js code and get it's dependencies.
content {String}
js code{Array}
an dependencies arrayanalyze.parseCSS(content)
Parse css (sass/less) code and get it's dependencies.
content {String}
css (sass/less) code{Array}
an dependencies arrayanalyze.parse(file[, matches])
Parse a file/directory, and get it's dependencies.
file {String}
file or dir pathmatches {String|Array}
minimatch rules (String
will be treat as a single rule)If matches
is specfied, the files under basedir (file
) will be filtered; otherwise all files except dot-started file (.xxx
, *nix hidden file) will be parsed.
{Array}
if file
is a File, then dependencies array will be return
{Object}
if file
is a directory, then a (file => dependencies) Object will be return, just like:
return {
'dir/index.js': [
'dep1',
'dep2',
...
],
'dir/index.css': [
'dep1',
'dep2',
...
]
}
analyze.analyze(entry[, options])
analyze dependencies of specified entry (eg. file path, file content, multiple files) recursively.
entry {Mixed}
type of entry
can be String
(file path) or Object
(file + content info), or multiple entries
{String}
the file path{Object}
the object of file and content { file: ..., content: ... }
{Array}
the array of file or file/content objectoptions {Object}
analyze options
{Number}
max recursive resolve depth (default is Infinity){Function}
custom resolve dep to standard format (e.g. ~xxx
=> xxx
){Function}
filter which deps can be resolved, will be invoked with (dep, currFile)
options.depResolve
will be invoked with params (dep, currFile, defaultResolve)
:
dep {String}
original dep stringcurrFile {String}
current file to resolvedefaultResolve {Function}
default dep resolve functionwill return a object like:
{
'/path/to/entry.js': {
deps: [{
parent: '/path/to/entry.js',
raw: 'react',
name: 'react',
module: 'react',
file: null,
}, ...],
modules: [
'react',
...
],
relatives: [
'/path/to/a.js',
...
]
}
}
dependency-analyze use different parser to parse code.
Use babylon to parse js code, these statements will be considered as a dependency:
import 'xxx'
require('xxx')
require.resolve('xxx')
Use RegExp to parse css code, @import
statement will be considered as a dependency.
Don't worry about @import
in css comments, they will be skipped
MIT
FAQs
js code dependency analyze
The npm package dependency-analyze receives a total of 0 weekly downloads. As such, dependency-analyze popularity was classified as not popular.
We found that dependency-analyze demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.