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

undirected-graph-typed

Package Overview
Dependencies
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

undirected-graph-typed - npm Package Compare versions

Comparing version 1.38.2 to 1.38.4

844

.dependency-cruiser.js
/** @type {import('dependency-cruiser').IConfiguration} */
module.exports = {
forbidden: [
/* rules from the 'recommended' preset: */
{
name: 'no-circular',
severity: 'warn',
comment:
'This dependency is part of a circular relationship. You might want to revise ' +
'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
from: {},
to: {
circular: true
}
},
{
name: 'no-orphans',
comment:
"This is an orphan module - it's likely not used (anymore?). Either use it or " +
"remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
"add an exception for it in your dependency-cruiser configuration. By default " +
"this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " +
"files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
severity: 'warn',
from: {
orphan: true,
pathNot: [
'(^|/)\\.[^/]+\\.(js|cjs|mjs|ts|json)$', // dot files
'\\.d\\.ts$', // TypeScript declaration files
'(^|/)tsconfig\\.json$', // TypeScript config
'(^|/)(babel|webpack)\\.config\\.(js|cjs|mjs|ts|json)$' // other configs
]
},
to: {},
},
{
name: 'no-deprecated-core',
comment:
'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +
"bound to exist - node doesn't deprecate lightly.",
severity: 'warn',
from: {},
to: {
dependencyTypes: [
'core'
],
path: [
'^(v8\/tools\/codemap)$',
'^(v8\/tools\/consarray)$',
'^(v8\/tools\/csvparser)$',
'^(v8\/tools\/logreader)$',
'^(v8\/tools\/profile_view)$',
'^(v8\/tools\/profile)$',
'^(v8\/tools\/SourceMap)$',
'^(v8\/tools\/splaytree)$',
'^(v8\/tools\/tickprocessor-driver)$',
'^(v8\/tools\/tickprocessor)$',
'^(node-inspect\/lib\/_inspect)$',
'^(node-inspect\/lib\/internal\/inspect_client)$',
'^(node-inspect\/lib\/internal\/inspect_repl)$',
'^(async_hooks)$',
'^(punycode)$',
'^(domain)$',
'^(constants)$',
'^(sys)$',
'^(_linklist)$',
'^(_stream_wrap)$'
],
}
},
{
name: 'not-to-deprecated',
comment:
'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +
'version of that module, or find an alternative. Deprecated modules are a security risk.',
severity: 'warn',
from: {},
to: {
dependencyTypes: [
'deprecated'
]
}
},
{
name: 'no-non-package-json',
severity: 'error',
comment:
"This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
"That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
"available on live with an non-guaranteed version. Fix it by adding the package to the dependencies " +
"in your package.json.",
from: {},
to: {
dependencyTypes: [
'npm-no-pkg',
'npm-unknown'
]
}
},
{
name: 'not-to-unresolvable',
comment:
"This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
'module: add it to your package.json. In all other cases you likely already know what to do.',
severity: 'error',
from: {},
to: {
couldNotResolve: true
}
},
{
name: 'no-duplicate-dep-types',
comment:
"Likely this module depends on an external ('npm') package that occurs more than once " +
"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
"maintenance problems later on.",
severity: 'warn',
from: {},
to: {
moreThanOneDependencyType: true,
// as it's pretty common to have a type import be a type only import
// _and_ (e.g.) a devDependency - don't consider type-only dependency
// types for this rule
dependencyTypesNot: ["type-only"]
}
},
forbidden: [
/* rules from the 'recommended' preset: */
{
name: 'no-circular',
severity: 'warn',
comment:
'This dependency is part of a circular relationship. You might want to revise ' +
'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',
from: {},
to: {
circular: true
}
},
{
name: 'no-orphans',
comment:
"This is an orphan module - it's likely not used (anymore?). Either use it or " +
"remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
"add an exception for it in your dependency-cruiser configuration. By default " +
"this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " +
"files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
severity: 'warn',
from: {
orphan: true,
pathNot: [
'(^|/)\\.[^/]+\\.(js|cjs|mjs|ts|json)$', // dot files
'\\.d\\.ts$', // TypeScript declaration files
'(^|/)tsconfig\\.json$', // TypeScript config
'(^|/)(babel|webpack)\\.config\\.(js|cjs|mjs|ts|json)$' // other configs
]
},
to: {},
},
{
name: 'no-deprecated-core',
comment:
'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +
"bound to exist - node doesn't deprecate lightly.",
severity: 'warn',
from: {},
to: {
dependencyTypes: [
'core'
],
path: [
'^(v8\/tools\/codemap)$',
'^(v8\/tools\/consarray)$',
'^(v8\/tools\/csvparser)$',
'^(v8\/tools\/logreader)$',
'^(v8\/tools\/profile_view)$',
'^(v8\/tools\/profile)$',
'^(v8\/tools\/SourceMap)$',
'^(v8\/tools\/splaytree)$',
'^(v8\/tools\/tickprocessor-driver)$',
'^(v8\/tools\/tickprocessor)$',
'^(node-inspect\/lib\/_inspect)$',
'^(node-inspect\/lib\/internal\/inspect_client)$',
'^(node-inspect\/lib\/internal\/inspect_repl)$',
'^(async_hooks)$',
'^(punycode)$',
'^(domain)$',
'^(constants)$',
'^(sys)$',
'^(_linklist)$',
'^(_stream_wrap)$'
],
}
},
{
name: 'not-to-deprecated',
comment:
'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +
'version of that module, or find an alternative. Deprecated modules are a security risk.',
severity: 'warn',
from: {},
to: {
dependencyTypes: [
'deprecated'
]
}
},
{
name: 'no-non-package-json',
severity: 'error',
comment:
"This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
"That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
"available on live with an non-guaranteed version. Fix it by adding the package to the dependencies " +
"in your package.json.",
from: {},
to: {
dependencyTypes: [
'npm-no-pkg',
'npm-unknown'
]
}
},
{
name: 'not-to-unresolvable',
comment:
"This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
'module: add it to your package.json. In all other cases you likely already know what to do.',
severity: 'error',
from: {},
to: {
couldNotResolve: true
}
},
{
name: 'no-duplicate-dep-types',
comment:
"Likely this module depends on an external ('npm') package that occurs more than once " +
"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
"maintenance problems later on.",
severity: 'warn',
from: {},
to: {
moreThanOneDependencyType: true,
// as it's pretty common to have a type import be a type only import
// _and_ (e.g.) a devDependency - don't consider type-only dependency
// types for this rule
dependencyTypesNot: ["type-only"]
}
},
/* rules you might want to tweak for your specific situation: */
{
name: 'not-to-spec',
comment:
'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +
"If there's something in a spec that's of use to other modules, it doesn't have that single " +
'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
severity: 'error',
from: {},
to: {
path: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
}
},
{
name: 'not-to-dev-dep',
severity: 'error',
comment:
"This module depends on an npm package from the 'devDependencies' section of your " +
'package.json. It looks like something that ships to production, though. To prevent problems ' +
"with npm packages that aren't there on production declare it (only!) in the 'dependencies'" +
'section of your package.json. If this module is development only - add it to the ' +
'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',
from: {
path: '^(src)',
pathNot: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
},
to: {
dependencyTypes: [
'npm-dev'
]
}
},
{
name: 'optional-deps-used',
severity: 'info',
comment:
"This module depends on an npm package that is declared as an optional dependency " +
"in your package.json. As this makes sense in limited situations only, it's flagged here. " +
"If you're using an optional dependency here by design - add an exception to your" +
"dependency-cruiser configuration.",
from: {},
to: {
dependencyTypes: [
'npm-optional'
]
}
},
{
name: 'peer-deps-used',
comment:
"This module depends on an npm package that is declared as a peer dependency " +
"in your package.json. This makes sense if your package is e.g. a plugin, but in " +
"other cases - maybe not so much. If the use of a peer dependency is intentional " +
"add an exception to your dependency-cruiser configuration.",
severity: 'warn',
from: {},
to: {
dependencyTypes: [
'npm-peer'
]
}
}
],
options: {
/* rules you might want to tweak for your specific situation: */
{
name: 'not-to-spec',
comment:
'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +
"If there's something in a spec that's of use to other modules, it doesn't have that single " +
'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
severity: 'error',
from: {},
to: {
path: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
}
},
{
name: 'not-to-dev-dep',
severity: 'error',
comment:
"This module depends on an npm package from the 'devDependencies' section of your " +
'package.json. It looks like something that ships to production, though. To prevent problems ' +
"with npm packages that aren't there on production declare it (only!) in the 'dependencies'" +
'section of your package.json. If this module is development only - add it to the ' +
'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',
from: {
path: '^(src)',
pathNot: '\\.(spec|test)\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\.md)$'
},
to: {
dependencyTypes: [
'npm-dev'
]
}
},
{
name: 'optional-deps-used',
severity: 'info',
comment:
"This module depends on an npm package that is declared as an optional dependency " +
"in your package.json. As this makes sense in limited situations only, it's flagged here. " +
"If you're using an optional dependency here by design - add an exception to your" +
"dependency-cruiser configuration.",
from: {},
to: {
dependencyTypes: [
'npm-optional'
]
}
},
{
name: 'peer-deps-used',
comment:
"This module depends on an npm package that is declared as a peer dependency " +
"in your package.json. This makes sense if your package is e.g. a plugin, but in " +
"other cases - maybe not so much. If the use of a peer dependency is intentional " +
"add an exception to your dependency-cruiser configuration.",
severity: 'warn',
from: {},
to: {
dependencyTypes: [
'npm-peer'
]
}
}
],
options: {
/* conditions specifying which files not to follow further when encountered:
- path: a regular expression to match
- dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/main/doc/rules-reference.md#dependencytypes-and-dependencytypesnot
for a complete list
*/
doNotFollow: {
path: ['node_modules', 'src/libs']
},
/* conditions specifying which files not to follow further when encountered:
- path: a regular expression to match
- dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/main/doc/rules-reference.md#dependencytypes-and-dependencytypesnot
for a complete list
*/
doNotFollow: {
path: ['node_modules', 'src/libs']
},
/* conditions specifying which dependencies to exclude
- path: a regular expression to match
- dynamic: a boolean indicating whether to ignore dynamic (true) or static (false) dependencies.
leave out if you want to exclude neither (recommended!)
*/
// exclude : {
// path: '',
// dynamic: true
// },
/* conditions specifying which dependencies to exclude
- path: a regular expression to match
- dynamic: a boolean indicating whether to ignore dynamic (true) or static (false) dependencies.
leave out if you want to exclude neither (recommended!)
*/
// exclude : {
// path: '',
// dynamic: true
// },
/* pattern specifying which files to include (regular expression)
dependency-cruiser will skip everything not matching this pattern
*/
// includeOnly : '',
/* pattern specifying which files to include (regular expression)
dependency-cruiser will skip everything not matching this pattern
*/
// includeOnly : '',
/* dependency-cruiser will include modules matching against the focus
regular expression in its output, as well as their neighbours (direct
dependencies and dependents)
*/
// focus : '',
/* dependency-cruiser will include modules matching against the focus
regular expression in its output, as well as their neighbours (direct
dependencies and dependents)
*/
// focus : '',
/* list of module systems to cruise */
// moduleSystems: ['amd', 'cjs', 'es6', 'tsd'],
/* list of module systems to cruise */
// moduleSystems: ['amd', 'cjs', 'es6', 'tsd'],
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/develop/'
to open it on your online repo or `vscode://file/${process.cwd()}/` to
open it in visual studio code),
*/
// prefix: '',
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/develop/'
to open it on your online repo or `vscode://file/${process.cwd()}/` to
open it in visual studio code),
*/
// prefix: '',
/* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
true: also detect dependencies that only exist before typescript-to-javascript compilation
"specify": for each dependency identify whether it only exists before compilation or also after
*/
tsPreCompilationDeps: true,
/*
list of extensions to scan that aren't javascript or compile-to-javascript.
Empty by default. Only put extensions in here that you want to take into
account that are _not_ parsable.
*/
// extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],
/* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
true: also detect dependencies that only exist before typescript-to-javascript compilation
"specify": for each dependency identify whether it only exists before compilation or also after
*/
tsPreCompilationDeps: true,
/* if true combines the package.jsons found from the module up to the base
folder the cruise is initiated from. Useful for how (some) mono-repos
manage dependencies & dependency definitions.
*/
// combinedDependencies: false,
/*
list of extensions to scan that aren't javascript or compile-to-javascript.
Empty by default. Only put extensions in here that you want to take into
account that are _not_ parsable.
*/
// extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],
/* if true leave symlinks untouched, otherwise use the realpath */
// preserveSymlinks: false,
/* if true combines the package.jsons found from the module up to the base
folder the cruise is initiated from. Useful for how (some) mono-repos
manage dependencies & dependency definitions.
*/
// combinedDependencies: false,
/* TypeScript project file ('tsconfig.json') to use for
(1) compilation and
(2) resolution (e.g. with the paths property)
/* if true leave symlinks untouched, otherwise use the realpath */
// preserveSymlinks: false,
The (optional) fileName attribute specifies which file to take (relative to
dependency-cruiser's current working directory). When not provided
defaults to './tsconfig.json'.
*/
tsConfig: {
fileName: 'tsconfig.json'
},
/* TypeScript project file ('tsconfig.json') to use for
(1) compilation and
(2) resolution (e.g. with the paths property)
/* Webpack configuration to use to get resolve options from.
The (optional) fileName attribute specifies which file to take (relative to
dependency-cruiser's current working directory). When not provided
defaults to './tsconfig.json'.
*/
tsConfig: {
fileName: 'tsconfig.json'
},
The (optional) fileName attribute specifies which file to take (relative
to dependency-cruiser's current working directory. When not provided defaults
to './webpack.conf.js'.
/* Webpack configuration to use to get resolve options from.
The (optional) `env` and `arguments` attributes contain the parameters to be passed if
your webpack config is a function and takes them (see webpack documentation
for details)
*/
// webpackConfig: {
// fileName: './webpack.config.js',
// env: {},
// arguments: {},
// },
The (optional) fileName attribute specifies which file to take (relative
to dependency-cruiser's current working directory. When not provided defaults
to './webpack.conf.js'.
/* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
for compilation (and whatever other naughty things babel plugins do to
source code). This feature is well tested and usable, but might change
behavior a bit over time (e.g. more precise results for used module
systems) without dependency-cruiser getting a major version bump.
*/
// babelConfig: {
// fileName: './.babelrc'
// },
The (optional) `env` and `arguments` attributes contain the parameters to be passed if
your webpack config is a function and takes them (see webpack documentation
for details)
*/
// webpackConfig: {
// fileName: './webpack.config.js',
// env: {},
// arguments: {},
// },
/* List of strings you have in use in addition to cjs/ es6 requires
& imports to declare module dependencies. Use this e.g. if you've
re-declared require, use a require-wrapper or use window.require as
a hack.
*/
// exoticRequireStrings: [],
/* options to pass on to enhanced-resolve, the package dependency-cruiser
uses to resolve module references to disk. You can set most of these
options in a webpack.conf.js - this section is here for those
projects that don't have a separate webpack config file.
/* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
for compilation (and whatever other naughty things babel plugins do to
source code). This feature is well tested and usable, but might change
behavior a bit over time (e.g. more precise results for used module
systems) without dependency-cruiser getting a major version bump.
*/
// babelConfig: {
// fileName: './.babelrc'
// },
Note: settings in webpack.conf.js override the ones specified here.
*/
enhancedResolveOptions: {
/* List of strings to consider as 'exports' fields in package.json. Use
['exports'] when you use packages that use such a field and your environment
supports it (e.g. node ^12.19 || >=14.7 or recent versions of webpack).
/* List of strings you have in use in addition to cjs/ es6 requires
& imports to declare module dependencies. Use this e.g. if you've
re-declared require, use a require-wrapper or use window.require as
a hack.
*/
// exoticRequireStrings: [],
/* options to pass on to enhanced-resolve, the package dependency-cruiser
uses to resolve module references to disk. You can set most of these
options in a webpack.conf.js - this section is here for those
projects that don't have a separate webpack config file.
If you have an `exportsFields` attribute in your webpack config, that one
will have precedence over the one specified here.
*/
exportsFields: ["exports"],
/* List of conditions to check for in the exports field. e.g. use ['imports']
if you're only interested in exposed es6 modules, ['require'] for commonjs,
or all conditions at once `(['import', 'require', 'node', 'default']`)
if anything goes for you. Only works when the 'exportsFields' array is
non-empty.
If you have a 'conditionNames' attribute in your webpack config, that one will
have precedence over the one specified here.
*/
conditionNames: ["import", "require", "node", "default"],
/*
The extensions, by default are the same as the ones dependency-cruiser
can access (run `npx depcruise --info` to see which ones that are in
_your_ environment. If that list is larger than what you need (e.g.
it contains .js, .jsx, .ts, .tsx, .cts, .mts - but you don't use
TypeScript you can pass just the extensions you actually use (e.g.
[".js", ".jsx"]). This can speed up the most expensive step in
dependency cruising (module resolution) quite a bit.
*/
// extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
/*
If your TypeScript project makes use of types specified in 'types'
fields in package.jsons of external dependencies, specify "types"
in addition to "main" in here, so enhanced-resolve (the resolver
dependency-cruiser uses) knows to also look there. You can also do
this if you're not sure, but still use TypeScript. In a future version
of dependency-cruiser this will likely become the default.
*/
mainFields: ["main", "types"],
},
reporterOptions: {
dot: {
/* pattern of modules that can be consolidated in the detailed
graphical dependency graph. The default pattern in this configuration
collapses everything in node_modules to one folder deep so you see
the external modules, but not the innards your app depends upon.
Note: settings in webpack.conf.js override the ones specified here.
*/
collapsePattern: 'node_modules/(@[^/]+/[^/]+|[^/]+)',
enhancedResolveOptions: {
/* List of strings to consider as 'exports' fields in package.json. Use
['exports'] when you use packages that use such a field and your environment
supports it (e.g. node ^12.19 || >=14.7 or recent versions of webpack).
/* Options to tweak the appearance of your graph.See
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
for details and some examples. If you don't specify a theme
don't worry - dependency-cruiser will fall back to the default one.
*/
// theme: {
// graph: {
// /* use splines: "ortho" for straight lines. Be aware though
// graphviz might take a long time calculating ortho(gonal)
// routings.
// */
// splines: "true"
// },
// modules: [
// {
// criteria: { matchesFocus: true },
// attributes: {
// fillcolor: "lime",
// penwidth: 2,
// },
// },
// {
// criteria: { matchesFocus: false },
// attributes: {
// fillcolor: "lightgrey",
// },
// },
// {
// criteria: { matchesReaches: true },
// attributes: {
// fillcolor: "lime",
// penwidth: 2,
// },
// },
// {
// criteria: { matchesReaches: false },
// attributes: {
// fillcolor: "lightgrey",
// },
// },
// {
// criteria: { source: "^src/model" },
// attributes: { fillcolor: "#ccccff" }
// },
// {
// criteria: { source: "^src/view" },
// attributes: { fillcolor: "#ccffcc" }
// },
// ],
// dependencies: [
// {
// criteria: { "rules[0].severity": "error" },
// attributes: { fontcolor: "red", color: "red" }
// },
// {
// criteria: { "rules[0].severity": "warn" },
// attributes: { fontcolor: "orange", color: "orange" }
// },
// {
// criteria: { "rules[0].severity": "info" },
// attributes: { fontcolor: "blue", color: "blue" }
// },
// {
// criteria: { resolved: "^src/model" },
// attributes: { color: "#0000ff77" }
// },
// {
// criteria: { resolved: "^src/view" },
// attributes: { color: "#00770077" }
// }
// ]
// }
},
archi: {
/* pattern of modules that can be consolidated in the high level
graphical dependency graph. If you use the high level graphical
dependency graph reporter (`archi`) you probably want to tweak
this collapsePattern to your situation.
*/
collapsePattern: '^(packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+|node_modules/(@[^/]+/[^/]+|[^/]+)',
If you have an `exportsFields` attribute in your webpack config, that one
will have precedence over the one specified here.
*/
exportsFields: ["exports"],
/* List of conditions to check for in the exports field. e.g. use ['imports']
if you're only interested in exposed es6 modules, ['require'] for commonjs,
or all conditions at once `(['import', 'require', 'node', 'default']`)
if anything goes for you. Only works when the 'exportsFields' array is
non-empty.
/* Options to tweak the appearance of your graph.See
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
for details and some examples. If you don't specify a theme
for 'archi' dependency-cruiser will use the one specified in the
dot section (see above), if any, and otherwise use the default one.
*/
// theme: {
// },
},
"text": {
"highlightFocused": true
},
If you have a 'conditionNames' attribute in your webpack config, that one will
have precedence over the one specified here.
*/
conditionNames: ["import", "require", "node", "default"],
/*
The extensions, by default are the same as the ones dependency-cruiser
can access (run `npx depcruise --info` to see which ones that are in
_your_ environment. If that list is larger than what you need (e.g.
it contains .js, .jsx, .ts, .tsx, .cts, .mts - but you don't use
TypeScript you can pass just the extensions you actually use (e.g.
[".js", ".jsx"]). This can speed up the most expensive step in
dependency cruising (module resolution) quite a bit.
*/
// extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
/*
If your TypeScript project makes use of types specified in 'types'
fields in package.jsons of external dependencies, specify "types"
in addition to "main" in here, so enhanced-resolve (the resolver
dependency-cruiser uses) knows to also look there. You can also do
this if you're not sure, but still use TypeScript. In a future version
of dependency-cruiser this will likely become the default.
*/
mainFields: ["main", "types"],
},
reporterOptions: {
dot: {
/* pattern of modules that can be consolidated in the detailed
graphical dependency graph. The default pattern in this configuration
collapses everything in node_modules to one folder deep so you see
the external modules, but not the innards your app depends upon.
*/
collapsePattern: 'node_modules/(@[^/]+/[^/]+|[^/]+)',
/* Options to tweak the appearance of your graph.See
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
for details and some examples. If you don't specify a theme
don't worry - dependency-cruiser will fall back to the default one.
*/
// theme: {
// graph: {
// /* use splines: "ortho" for straight lines. Be aware though
// graphviz might take a long time calculating ortho(gonal)
// routings.
// */
// splines: "true"
// },
// modules: [
// {
// criteria: { matchesFocus: true },
// attributes: {
// fillcolor: "lime",
// penwidth: 2,
// },
// },
// {
// criteria: { matchesFocus: false },
// attributes: {
// fillcolor: "lightgrey",
// },
// },
// {
// criteria: { matchesReaches: true },
// attributes: {
// fillcolor: "lime",
// penwidth: 2,
// },
// },
// {
// criteria: { matchesReaches: false },
// attributes: {
// fillcolor: "lightgrey",
// },
// },
// {
// criteria: { source: "^src/model" },
// attributes: { fillcolor: "#ccccff" }
// },
// {
// criteria: { source: "^src/view" },
// attributes: { fillcolor: "#ccffcc" }
// },
// ],
// dependencies: [
// {
// criteria: { "rules[0].severity": "error" },
// attributes: { fontcolor: "red", color: "red" }
// },
// {
// criteria: { "rules[0].severity": "warn" },
// attributes: { fontcolor: "orange", color: "orange" }
// },
// {
// criteria: { "rules[0].severity": "info" },
// attributes: { fontcolor: "blue", color: "blue" }
// },
// {
// criteria: { resolved: "^src/model" },
// attributes: { color: "#0000ff77" }
// },
// {
// criteria: { resolved: "^src/view" },
// attributes: { color: "#00770077" }
// }
// ]
// }
},
archi: {
/* pattern of modules that can be consolidated in the high level
graphical dependency graph. If you use the high level graphical
dependency graph reporter (`archi`) you probably want to tweak
this collapsePattern to your situation.
*/
collapsePattern: '^(packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+|node_modules/(@[^/]+/[^/]+|[^/]+)',
/* Options to tweak the appearance of your graph.See
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
for details and some examples. If you don't specify a theme
for 'archi' dependency-cruiser will use the one specified in the
dot section (see above), if any, and otherwise use the default one.
*/
// theme: {
// },
},
"text": {
"highlightFocused": true
},
}
}
}
};
// generated: dependency-cruiser@13.1.1 on 2023-08-02T09:11:55.676Z
module.exports = {
'extends': [
'plugin:@typescript-eslint/recommended',
'prettier'
],
'rules': {
'react/display-name': 'off',
'@next/next/no-img-element': 'off',
'react/no-unescaped-entities': 'off',
'import/no-anonymous-default-export': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
// add new line above comment
'lines-around-comment': [
'error',
{
'beforeLineComment': false,
'beforeBlockComment': true,
'allowBlockStart': true,
'allowClassStart': true,
'allowObjectStart': true,
'allowArrayStart': true
}
'extends': [
'plugin:@typescript-eslint/recommended',
'prettier'
],
// add new line above return
'newline-before-return': 'off',
// add new line below import
'import/newline-after-import': [
'error',
{
'count': 1
}
'rules': {
'react/display-name': 'off',
'@next/next/no-img-element': 'off',
'react/no-unescaped-entities': 'off',
'import/no-anonymous-default-export': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
// add new line above comment
'lines-around-comment': [
'error',
{
'beforeLineComment': false,
'beforeBlockComment': true,
'allowBlockStart': true,
'allowClassStart': true,
'allowObjectStart': true,
'allowArrayStart': true
}
],
// add new line above return
'newline-before-return': 'off',
// add new line below import
'import/newline-after-import': [
'error',
{
'count': 1
}
],
'@typescript-eslint/ban-types': [
'error',
{
'extendDefaults': true,
'types': {
'{}': false
}
}
]
},
'plugins': [
'import'
],
'@typescript-eslint/ban-types': [
'error',
{
'extendDefaults': true,
'types': {
'{}': false
'settings': {
'import/parsers': {
'@typescript-eslint/parser': [
'.ts',
'.tsx'
]
},
'import/resolver': {
'typescript': {
'alwaysTryTypes': true,
'project': [
'./tsconfig.json'
]
}
}
}
]
},
'plugins': [
'import'
],
'settings': {
'import/parsers': {
'@typescript-eslint/parser': [
'.ts',
'.tsx'
]
},
'import/resolver': {
'typescript': {
'alwaysTryTypes': true,
'project': [
'./tsconfig.json'
]
}
}
}
}
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
bracketSameLine: false,
jsxSingleQuote: true,
printWidth: 120,
proseWrap: 'preserve',
quoteProps: 'as-needed',
requirePragma: false,
singleQuote: true,
tabWidth: 2,
trailingComma: 'none',
useTabs: false
arrowParens: 'avoid',
bracketSpacing: true,
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
bracketSameLine: false,
jsxSingleQuote: true,
printWidth: 120,
proseWrap: 'preserve',
quoteProps: 'as-needed',
requirePragma: false,
singleQuote: true,
tabWidth: 2,
trailingComma: 'none',
useTabs: false
}

@@ -1,2 +0,131 @@

{"/Users/revone/projects/data-structure-typed-individuals/undirected-graph-typed/src/index.ts": {"path":"/Users/revone/projects/data-structure-typed-individuals/undirected-graph-typed/src/index.ts","statementMap":{"0":{"start":{"line":8,"column":0},"end":{"line":8,"column":9}},"1":{"start":{"line":8,"column":9},"end":{"line":8,"column":27}},"2":{"start":{"line":8,"column":27},"end":{"line":8,"column":43}},"3":{"start":{"line":8,"column":43},"end":{"line":8,"column":89}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":8,"column":9},"end":{"line":8,"column":25}},"loc":{"start":{"line":8,"column":9},"end":{"line":8,"column":27}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":8,"column":27},"end":{"line":8,"column":41}},"loc":{"start":{"line":8,"column":27},"end":{"line":8,"column":43}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":8,"column":43},"end":{"line":8,"column":58}},"loc":{"start":{"line":8,"column":43},"end":{"line":8,"column":89}}}},"branchMap":{},"s":{"0":1,"1":7,"2":3,"3":5},"f":{"0":6,"1":2,"2":4},"b":{}}
{
"/Users/revone/projects/data-structure-typed-individuals/undirected-graph-typed/src/index.ts": {
"path": "/Users/revone/projects/data-structure-typed-individuals/undirected-graph-typed/src/index.ts",
"statementMap": {
"0": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 8,
"column": 9
}
},
"1": {
"start": {
"line": 8,
"column": 9
},
"end": {
"line": 8,
"column": 27
}
},
"2": {
"start": {
"line": 8,
"column": 27
},
"end": {
"line": 8,
"column": 43
}
},
"3": {
"start": {
"line": 8,
"column": 43
},
"end": {
"line": 8,
"column": 89
}
}
},
"fnMap": {
"0": {
"name": "(anonymous_0)",
"decl": {
"start": {
"line": 8,
"column": 9
},
"end": {
"line": 8,
"column": 25
}
},
"loc": {
"start": {
"line": 8,
"column": 9
},
"end": {
"line": 8,
"column": 27
}
}
},
"1": {
"name": "(anonymous_1)",
"decl": {
"start": {
"line": 8,
"column": 27
},
"end": {
"line": 8,
"column": 41
}
},
"loc": {
"start": {
"line": 8,
"column": 27
},
"end": {
"line": 8,
"column": 43
}
}
},
"2": {
"name": "(anonymous_2)",
"decl": {
"start": {
"line": 8,
"column": 43
},
"end": {
"line": 8,
"column": 58
}
},
"loc": {
"start": {
"line": 8,
"column": 43
},
"end": {
"line": 8,
"column": 89
}
}
}
},
"branchMap": {},
"s": {
"0": 1,
"1": 7,
"2": 3,
"3": 5
},
"f": {
"0": 6,
"1": 2,
"2": 4
},
"b": {}
}
}

@@ -1,3 +0,60 @@

{"total": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":4,"covered":4,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
,"/Users/revone/projects/data-structure-typed-individuals/undirected-graph-typed/src/index.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":4,"covered":4,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
{
"total": {
"lines": {
"total": 1,
"covered": 1,
"skipped": 0,
"pct": 100
},
"statements": {
"total": 4,
"covered": 4,
"skipped": 0,
"pct": 100
},
"functions": {
"total": 3,
"covered": 3,
"skipped": 0,
"pct": 100
},
"branches": {
"total": 0,
"covered": 0,
"skipped": 0,
"pct": 100
},
"branchesTrue": {
"total": 0,
"covered": 0,
"skipped": 0,
"pct": "Unknown"
}
},
"/Users/revone/projects/data-structure-typed-individuals/undirected-graph-typed/src/index.ts": {
"lines": {
"total": 1,
"covered": 1,
"skipped": 0,
"pct": 100
},
"functions": {
"total": 3,
"covered": 3,
"skipped": 0,
"pct": 100
},
"statements": {
"total": 4,
"covered": 4,
"skipped": 0,
"pct": 100
},
"branches": {
"total": 0,
"covered": 0,
"skipped": 0,
"pct": 100
}
}
}
/* eslint-disable */
var addSorting = (function() {
var addSorting = (function () {
'use strict';

@@ -14,2 +14,3 @@ var cols,

}
// returns the thead element of the summary table

@@ -19,2 +20,3 @@ function getTableHeader() {

}
// returns the tbody element of the summary table

@@ -24,2 +26,3 @@ function getTableBody() {

}
// returns the th element for nth column

@@ -79,2 +82,3 @@ function getNthColumn(n) {

}
// attaches a data attribute to every tr element with an object

@@ -100,2 +104,3 @@ // of data values keyed by column name

}
// loads all row data

@@ -110,6 +115,7 @@ function loadData() {

}
// sorts the table using the data for the ith column
function sortByIndex(index, desc) {
var key = cols[index].key,
sorter = function(a, b) {
sorter = function (a, b) {
a = a.data[key];

@@ -126,3 +132,3 @@ b = b.data[key];

if (desc) {
finalSorter = function(a, b) {
finalSorter = function (a, b) {
return -1 * sorter(a, b);

@@ -143,2 +149,3 @@ };

}
// removes sort indicators for current column being sorted

@@ -152,2 +159,3 @@ function removeSortIndicators() {

}
// adds sort indicators for current column being sorted

@@ -159,2 +167,3 @@ function addSortIndicators() {

}
// adds event listeners for all sorter widgets

@@ -167,3 +176,3 @@ function enableUI() {

return function() {
return function () {
var desc = col.defaultDescSort;

@@ -194,4 +203,5 @@

}
// adds sorting functionality to the UI
return function() {
return function () {
if (!getTable()) {

@@ -198,0 +208,0 @@ return;

@@ -8,3 +8,3 @@ /**

*/
import type { BFSCallback, BFSCallbackReturn, BinaryTreeNodeKey, BinaryTreeNodeNested, BinaryTreeOptions, MapCallback, MapCallbackReturn } from '../../types';
import type { BFSCallback, BinaryTreeNodeKey, BinaryTreeNodeNested, BinaryTreeOptions, MapCallback } from '../../types';
import { BinaryTreeDeletedResult, DFSOrderPattern, FamilyPosition, IterationType } from '../../types';

@@ -211,3 +211,3 @@ import { IBinaryTree } from '../../interfaces';

*/
getNodes(nodeProperty: BinaryTreeNodeKey | N, callback?: MapCallback<N>, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
getNodes<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(nodeProperty: BinaryTreeNodeKey | N, callback?: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
/**

@@ -230,3 +230,3 @@ * The function checks if a binary tree has a node with a given property or key.

*/
has(nodeProperty: BinaryTreeNodeKey | N, callback?: MapCallback<N>, beginRoot?: N | null, iterationType?: IterationType): boolean;
has<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(nodeProperty: BinaryTreeNodeKey | N, callback?: C, beginRoot?: N | null, iterationType?: IterationType): boolean;
/**

@@ -247,3 +247,3 @@ * The function `get` returns the first node in a binary tree that matches the given property or key.

*/
get(nodeProperty: BinaryTreeNodeKey | N, callback?: MapCallback<N>, beginRoot?: N | null, iterationType?: IterationType): N | null;
get<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(nodeProperty: BinaryTreeNodeKey | N, callback?: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
/**

@@ -317,3 +317,3 @@ * The function `getPathToRoot` returns an array of nodes starting from a given node and traversing

*/
subTreeTraverse(callback?: MapCallback<N>, beginRoot?: N | BinaryTreeNodeKey | null, iterationType?: IterationType): MapCallbackReturn<N>[];
subTreeTraverse<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(callback?: C, beginRoot?: N | BinaryTreeNodeKey | null, iterationType?: IterationType): ReturnType<C>[];
/**

@@ -334,3 +334,3 @@ * The `dfs` function performs a depth-first search traversal on a binary tree, executing a callback

*/
dfs(callback?: MapCallback<N>, pattern?: DFSOrderPattern, beginRoot?: N | null, iterationType?: IterationType): MapCallbackReturn<N>[];
dfs<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null, iterationType?: IterationType): ReturnType<C>[];
/**

@@ -353,3 +353,3 @@ * The bfs function performs a breadth-first search traversal on a binary tree, executing a callback

*/
bfs(callback?: BFSCallback<N>, withLevel?: boolean, beginRoot?: N | null, iterationType?: IterationType): BFSCallbackReturn<N>[];
bfs<C extends BFSCallback<N> = BFSCallback<N, BinaryTreeNodeKey>>(callback?: C, withLevel?: boolean, beginRoot?: N | null, iterationType?: IterationType): ReturnType<C>[];
/**

@@ -375,3 +375,3 @@ * The function returns the predecessor node of a given node in a binary tree.

*/
morris(callback?: MapCallback<N>, pattern?: DFSOrderPattern, beginRoot?: N | null): MapCallbackReturn<N>[];
morris<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(callback?: C, pattern?: DFSOrderPattern, beginRoot?: N | null): ReturnType<C>[];
/**

@@ -391,3 +391,3 @@ * Swap the data of two nodes in the binary tree.

*/
protected _defaultCallbackByKey: MapCallback<N>;
protected _defaultCallbackByKey: (node: N) => number;
/**

@@ -394,0 +394,0 @@ * The function `_addTo` adds a new node to a binary tree if there is an available position.

@@ -8,3 +8,3 @@ /**

*/
import type { BinaryTreeNodeKey, BSTComparator, BSTNodeNested, BSTOptions, MapCallback, MapCallbackReturn } from '../../types';
import type { BinaryTreeNodeKey, BSTComparator, BSTNodeNested, BSTOptions, MapCallback } from '../../types';
import { CP, IterationType } from '../../types';

@@ -76,3 +76,3 @@ import { BinaryTree, BinaryTreeNode } from './binary-tree';

*/
get(nodeProperty: BinaryTreeNodeKey | N, callback?: MapCallback<N>, beginRoot?: N | null, iterationType?: IterationType): N | null;
get<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(nodeProperty: BinaryTreeNodeKey | N, callback?: C, beginRoot?: N | null, iterationType?: IterationType): N | null;
/**

@@ -115,3 +115,3 @@ * The function `lastKey` returns the key of the rightmost node if the comparison result is less

*/
getNodes(nodeProperty: BinaryTreeNodeKey | N, callback?: MapCallback<N>, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
getNodes<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(nodeProperty: BinaryTreeNodeKey | N, callback?: C, onlyOne?: boolean, beginRoot?: N | null, iterationType?: IterationType): N[];
/**

@@ -134,3 +134,3 @@ * The `lesserOrGreaterTraverse` function traverses a binary tree and applies a callback function to

*/
lesserOrGreaterTraverse(callback?: MapCallback<N>, lesserOrGreater?: CP, targetNode?: N | BinaryTreeNodeKey | null, iterationType?: IterationType): MapCallbackReturn<N>;
lesserOrGreaterTraverse<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(callback?: C, lesserOrGreater?: CP, targetNode?: N | BinaryTreeNodeKey | null, iterationType?: IterationType): ReturnType<C>[];
/**

@@ -137,0 +137,0 @@ * Balancing Adjustment:

@@ -22,3 +22,3 @@ import { BinaryTreeNode } from '../../../data-structures';

export type BinaryTreeNodeKey = number;
export type BFSCallback<N> = (node: N, level?: number) => any;
export type BFSCallback<N, D = any> = (node: N, level?: number) => D;
export type BFSCallbackReturn<N> = ReturnType<BFSCallback<N>>;

@@ -25,0 +25,0 @@ export type BinaryTreeDeletedResult<N> = {

export type Comparator<T> = (a: T, b: T) => number;
export type DFSOrderPattern = 'pre' | 'in' | 'post';
export type MapCallback<N> = (node: N) => any;
export type MapCallback<N, D = any> = (node: N) => D;
export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;

@@ -5,0 +5,0 @@ export declare enum CP {

module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/test/**/*.test.ts', '<rootDir>/test/**/*.test.js'],
collectCoverage: true,
coverageReporters: ['clover', 'json', 'lcov', ['text', {skipFull: true}], "json-summary"],
coverageDirectory: 'coverage'
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/test/**/*.test.ts', '<rootDir>/test/**/*.test.js'],
collectCoverage: true,
coverageReporters: ['clover', 'json', 'lcov', ['text', {skipFull: true}], "json-summary"],
coverageDirectory: 'coverage'
};
{
"name": "undirected-graph-typed",
"version": "1.38.2",
"version": "1.38.4",
"description": "Undirected Graph. Javascript & Typescript Data Structure.",

@@ -145,3 +145,6 @@ "main": "dist/index.js",

"typescript": "^4.9.5"
},
"dependencies": {
"data-structure-typed": "^1.38.4"
}
}

@@ -10,5 +10,8 @@ ![NPM](https://img.shields.io/npm/l/undirected-graph-typed)

# What
## Brief
This is a standalone Undirected Graph data structure from the data-structure-typed collection. If you wish to access more data structures or advanced features, you can transition to directly installing the complete [data-structure-typed](https://www.npmjs.com/package/data-structure-typed) package
This is a standalone Undirected Graph data structure from the data-structure-typed collection. If you wish to access
more data structures or advanced features, you can transition to directly installing the
complete [data-structure-typed](https://www.npmjs.com/package/data-structure-typed) package

@@ -18,18 +21,29 @@ # How

## install
### npm
```bash
npm i undirected-graph-typed --save
```
### yarn
```bash
yarn add undirected-graph-typed
```
### methods
![](https://github.com/zrwusa/assets/blob/master/images/data-structure-typed/methods-8bit/undirected-graph.png?raw=true)
### snippet
#### TS
```typescript
```
#### JS
```javascript

@@ -39,3 +53,2 @@

## API docs & Examples

@@ -242,3 +255,2 @@

# Why

@@ -245,0 +257,0 @@

@@ -155,3 +155,3 @@ /**

this._balanceFactor(A) // second O(1)
) {
) {
case -2:

@@ -158,0 +158,0 @@ if (A && A.left) {

@@ -20,3 +20,3 @@ /**

*/
constructor({frequency = 0, max}: { frequency?: number; max: number }) {
constructor({frequency = 0, max}: {frequency?: number; max: number}) {
this._freq = frequency;

@@ -23,0 +23,0 @@ this._max = max;

@@ -410,3 +410,3 @@ /**

const stack: { node: N; depth: number }[] = [{node: beginRoot, depth: 0}];
const stack: {node: N; depth: number}[] = [{node: beginRoot, depth: 0}];
let maxHeight = 0;

@@ -516,5 +516,5 @@

*/
getNodes(
getNodes<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
nodeProperty: BinaryTreeNodeKey | N,
callback: MapCallback<N> = this._defaultCallbackByKey,
callback: C = this._defaultCallbackByKey as C,
onlyOne = false,

@@ -575,5 +575,5 @@ beginRoot: N | null = this.root,

*/
has(
has<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
nodeProperty: BinaryTreeNodeKey | N,
callback: MapCallback<N> = this._defaultCallbackByKey,
callback: C = this._defaultCallbackByKey as C,
beginRoot = this.root,

@@ -601,5 +601,5 @@ iterationType = this.iterationType

*/
get(
get<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
nodeProperty: BinaryTreeNodeKey | N,
callback: MapCallback<N> = this._defaultCallbackByKey,
callback: C = this._defaultCallbackByKey as C,
beginRoot = this.root,

@@ -768,7 +768,7 @@ iterationType = this.iterationType

*/
subTreeTraverse(
callback: MapCallback<N> = this._defaultCallbackByKey,
subTreeTraverse<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
callback: C = this._defaultCallbackByKey as C,
beginRoot: N | BinaryTreeNodeKey | null = this.root,
iterationType = this.iterationType
): MapCallbackReturn<N>[] {
): ReturnType<C>[] {
if (typeof beginRoot === 'number') beginRoot = this.get(beginRoot);

@@ -816,8 +816,8 @@

*/
dfs(
callback: MapCallback<N> = this._defaultCallbackByKey,
dfs<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
callback: C = this._defaultCallbackByKey as C,
pattern: DFSOrderPattern = 'in',
beginRoot: N | null = this.root,
iterationType: IterationType = IterationType.ITERATIVE
): MapCallbackReturn<N>[] {
): ReturnType<C>[] {
if (!beginRoot) return [];

@@ -851,3 +851,3 @@ const ans: MapCallbackReturn<N>[] = [];

// 0: visit, 1: print
const stack: { opt: 0 | 1; node: N | null | undefined }[] = [{opt: 0, node: beginRoot}];
const stack: {opt: 0 | 1; node: N | null | undefined}[] = [{opt: 0, node: beginRoot}];

@@ -906,8 +906,8 @@ while (stack.length > 0) {

*/
bfs(
callback: BFSCallback<N> = this._defaultCallbackByKey,
bfs<C extends BFSCallback<N> = BFSCallback<N, BinaryTreeNodeKey>>(
callback: C = this._defaultCallbackByKey as C,
withLevel: boolean = false,
beginRoot: N | null = this.root,
iterationType = this.iterationType
): BFSCallbackReturn<N>[] {
): ReturnType<C>[] {
if (!beginRoot) return [];

@@ -975,7 +975,7 @@

*/
morris(
callback: MapCallback<N> = this._defaultCallbackByKey,
morris<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
callback: C = this._defaultCallbackByKey as C,
pattern: DFSOrderPattern = 'in',
beginRoot: N | null = this.root
): MapCallbackReturn<N>[] {
): ReturnType<C>[] {
if (beginRoot === null) return [];

@@ -1090,3 +1090,3 @@ const ans: MapCallbackReturn<N>[] = [];

protected _defaultCallbackByKey: MapCallback<N> = node => node.key;
protected _defaultCallbackByKey: (node: N) => number = node => node.key;

@@ -1093,0 +1093,0 @@ /**

@@ -241,5 +241,5 @@ /**

*/
override get(
override get<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
nodeProperty: BinaryTreeNodeKey | N,
callback: MapCallback<N> = this._defaultCallbackByKey,
callback: C = this._defaultCallbackByKey as C,
beginRoot = this.root,

@@ -293,5 +293,5 @@ iterationType = this.iterationType

*/
override getNodes(
override getNodes<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
nodeProperty: BinaryTreeNodeKey | N,
callback: MapCallback<N> = this._defaultCallbackByKey,
callback: C = this._defaultCallbackByKey as C,
onlyOne = false,

@@ -368,8 +368,8 @@ beginRoot: N | null = this.root,

*/
lesserOrGreaterTraverse(
callback: MapCallback<N> = this._defaultCallbackByKey,
lesserOrGreaterTraverse<C extends MapCallback<N> = MapCallback<N, BinaryTreeNodeKey>>(
callback: C = this._defaultCallbackByKey as C,
lesserOrGreater: CP = CP.lt,
targetNode: N | BinaryTreeNodeKey | null = this.root,
iterationType = this.iterationType
): MapCallbackReturn<N> {
): ReturnType<C>[] {
if (typeof targetNode === 'number') targetNode = this.get(targetNode);

@@ -376,0 +376,0 @@ const ans: MapCallbackReturn<N>[] = [];

@@ -40,3 +40,4 @@ /**

extends AVLTree<N>
implements IBinaryTree<N> {
implements IBinaryTree<N>
{
/**

@@ -43,0 +44,0 @@ * The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to

@@ -108,3 +108,4 @@ /**

E extends AbstractEdge<any> = AbstractEdge<any>
> implements IGraph<V, E> {
> implements IGraph<V, E>
{
private _vertices: Map<VertexKey, V> = new Map<VertexKey, V>();

@@ -557,10 +558,10 @@

getMinDist &&
distMap.forEach((d, v) => {
if (v !== srcVertex) {
if (d < minDist) {
minDist = d;
if (genPaths) minDest = v;
distMap.forEach((d, v) => {
if (v !== srcVertex) {
if (d < minDist) {
minDist = d;
if (genPaths) minDest = v;
}
}
}
});
});

@@ -627,3 +628,3 @@ genPaths && getPaths(minDest);

const heap = new PriorityQueue<{ key: number; val: V }>((a, b) => a.key - b.key);
const heap = new PriorityQueue<{key: number; val: V}>((a, b) => a.key - b.key);
heap.add({key: 0, val: srcVertex});

@@ -857,3 +858,3 @@

*/
floyd(): { costs: number[][]; predecessor: (V | null)[][] } {
floyd(): {costs: number[][]; predecessor: (V | null)[][]} {
const idAndVertices = [...this._vertices];

@@ -860,0 +861,0 @@ const n = idAndVertices.length;

@@ -67,3 +67,4 @@ /**

extends AbstractGraph<V, E>
implements IGraph<V, E> {
implements IGraph<V, E>
{
/**

@@ -70,0 +71,0 @@ * The constructor function initializes an instance of a class.

@@ -54,7 +54,8 @@ /**

export class UndirectedGraph<
V extends UndirectedVertex<any> = UndirectedVertex,
E extends UndirectedEdge<any> = UndirectedEdge
>
V extends UndirectedVertex<any> = UndirectedVertex,
E extends UndirectedEdge<any> = UndirectedEdge
>
extends AbstractGraph<V, E>
implements IGraph<V, E> {
implements IGraph<V, E>
{
/**

@@ -61,0 +62,0 @@ * The constructor initializes a new Map object to store edges.

@@ -160,3 +160,3 @@ import {HashFunction} from '../../types';

* entries(): IterableIterator<[K, V]> {
*entries(): IterableIterator<[K, V]> {
for (const bucket of this.table) {

@@ -163,0 +163,0 @@ if (bucket) {

@@ -1,2 +0,1 @@

export class TreeMap {
}
export class TreeMap {}

@@ -1,2 +0,1 @@

export class TreeSet {
}
export class TreeSet {}

@@ -493,3 +493,3 @@ /**

* [Symbol.iterator]() {
*[Symbol.iterator]() {
let current = this.head;

@@ -496,0 +496,0 @@

@@ -17,3 +17,3 @@ /**

*/
constructor(options: { row: number; col: number; initialVal?: V }) {
constructor(options: {row: number; col: number; initialVal?: V}) {
const {row, col, initialVal} = options;

@@ -20,0 +20,0 @@ this._matrix = new Array(row).fill(undefined).map(() => new Array(col).fill(initialVal || 0));

@@ -13,4 +13,3 @@ /**

public w: number = 1 // needed for matrix multiplication
) {
}
) {}

@@ -17,0 +16,0 @@ /**

@@ -12,4 +12,3 @@ /**

// O(1) time complexity of adding at the beginning and the end
export class Deque<E = any> extends DoublyLinkedList<E> {
}
export class Deque<E = any> extends DoublyLinkedList<E> {}

@@ -24,5 +23,5 @@ // O(1) time complexity of obtaining the value

private _nodes: { [key: number]: E } = {};
private _nodes: {[key: number]: E} = {};
get nodes(): { [p: number]: E } {
get nodes(): {[p: number]: E} {
return this._nodes;

@@ -162,3 +161,3 @@ }

protected _seNodes(value: { [p: number]: E }) {
protected _seNodes(value: {[p: number]: E}) {
this._nodes = value;

@@ -165,0 +164,0 @@ }

@@ -186,3 +186,3 @@ /**

* [Symbol.iterator]() {
*[Symbol.iterator]() {
for (const item of this.nodes) {

@@ -189,0 +189,0 @@ yield item;

@@ -27,3 +27,3 @@ import {BinaryTreeNode} from '../../../data-structures';

export type BFSCallback<N> = (node: N, level?: number) => any;
export type BFSCallback<N, D = any> = (node: N, level?: number) => D;

@@ -30,0 +30,0 @@ export type BFSCallbackReturn<N> = ReturnType<BFSCallback<N>>;

export type Direction = 'up' | 'right' | 'down' | 'left';
export type Turning = { [key in Direction]: Direction };
export type Turning = {[key in Direction]: Direction};

@@ -5,0 +5,0 @@ export type NavigatorParams<T = any> = {

@@ -5,3 +5,3 @@ export type Comparator<T> = (a: T, b: T) => number;

export type MapCallback<N> = (node: N) => any;
export type MapCallback<N, D = any> = (node: N) => D;

@@ -8,0 +8,0 @@ export type MapCallbackReturn<N> = ReturnType<MapCallback<N>>;

export type ToThunkFn = () => ReturnType<TrlFn>;
export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
export type TrlFn = (...args: any[]) => any;

@@ -4,0 +4,0 @@ export type TrlAsyncFn = (...args: any[]) => any;

@@ -1,4 +0,4 @@

export type KeyValueObject = { [key: string]: any };
export type KeyValueObject = {[key: string]: any};
export type KeyValueObjectWithKey = { [key: string]: any; key: string | number | symbol };
export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol};

@@ -5,0 +5,0 @@ export type NonNumberNonObjectButDefined = string | boolean | symbol | null;

@@ -29,5 +29,4 @@ {

},
"include": [
"src",
"src"
],

@@ -34,0 +33,0 @@ "exclude": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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