MCPcopy
hub / github.com/josdejong/mathjs / factory

Function factory

src/utils/factory.js:30–50  ·  view source on GitHub ↗
(name, dependencies, create, meta)

Source from the content-addressed store, hash-verified

28 * @returns {function}
29 */
30export function factory (name, dependencies, create, meta) {
31 function assertAndCreate (scope) {
32 // we only pass the requested dependencies to the factory function
33 // to prevent functions to rely on dependencies that are not explicitly
34 // requested.
35 const deps = pickShallow(scope, dependencies.map(stripOptionalNotation))
36
37 assertDependencies(name, dependencies, scope)
38
39 return create(deps)
40 }
41
42 assertAndCreate.isFactory = true
43 assertAndCreate.fn = name
44 assertAndCreate.dependencies = dependencies.slice().sort()
45 if (meta) {
46 assertAndCreate.meta = meta
47 }
48
49 return assertAndCreate
50}
51
52/**
53 * Sort all factories such that when loading in order, the dependencies are resolved.

Callers 15

factory.test.jsFile · 0.90
import.test.jsFile · 0.90
constants.jsFile · 0.90
recreateFactoryFunction · 0.90
factoriesNumber.jsFile · 0.90
createNumberFactoryFunction · 0.90
sinh.jsFile · 0.90
sec.jsFile · 0.90
cosh.jsFile · 0.90
cot.jsFile · 0.90
sech.jsFile · 0.90

Calls 1

sortMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…