MCPcopy Index your code
hub / github.com/josdejong/mathjs / generateFunctionsFiles

Function generateFunctionsFiles

tools/entryGenerator.js:271–445  ·  view source on GitHub ↗

* Generate index files like * pureFunctionsAny.generated.js * impureFunctionsAny.generated.js

({ suffix, factories, entryFolder })

Source from the content-addressed store, hash-verified

269 * impureFunctionsAny.generated.js
270 */
271function generateFunctionsFiles ({ suffix, factories, entryFolder }) {
272 const braceOpen = '{' // a hack to be able to create a single brace open character in handlebars
273
274 const sortedFactories = sortFactories(Object.values(factories))
275
276 // sort the factories, and split them in three groups:
277 // - transform: the transform functions
278 // - impure: the functions that depend on `math` or `mathWithTransform` (directly or indirectly),
279 // - pure: the rest
280 const pureFactories = []
281 const impureFactories = []
282 const transformFactories = []
283 sortedFactories
284 .filter(factory => !DEPRECATED_FACTORIES[factory.fn])
285 .forEach(factory => {
286 if (isTransform(factory)) {
287 transformFactories.push(factory)
288 } else if (
289 factory.dependencies.includes('math') ||
290 factory.dependencies.includes( 'mathWithTransform') ||
291 factory.dependencies.includes( 'classes') ||
292 isTransform(factory) ||
293 factory.dependencies.some(dependency => {
294 return impureFactories.find(f => f.fn === stripOptionalNotation(dependency))
295 })
296 ) {
297 impureFactories.push(factory)
298 } else {
299 pureFactories.push(factory)
300 }
301 })
302
303 // a map containing:
304 // {
305 // 'sqrt': true,
306 // 'subset': true,
307 // ...
308 // }
309 const pureExists = {
310 config: true
311 }
312 pureFactories.forEach(factory => {
313 pureExists[factory.fn] = true
314 })
315
316 const impureExists = {
317 ...pureExists
318 }
319 impureFactories.forEach(factory => {
320 impureExists[factory.fn] = true
321 })
322
323 const math = sortedFactories
324 .filter(factory => !isClass(factory))
325 .filter(factory => !isTransform(factory))
326 .map(factory => {
327 return {
328 name: factory.fn,

Callers 1

generateEntryFilesFunction · 0.85

Calls 8

isTransformFunction · 0.85
isClassFunction · 0.85
findKeyFunction · 0.85
sortFactoriesFunction · 0.70
stripOptionalNotationFunction · 0.70
forEachMethod · 0.65
filterMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…