This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const sortDeps = (keys, packetList) => { | |
| const keyRed = keys.reduce((acc, element) => { | |
| if (packetList[element] instanceof Array && packetList[element].length === 0 || !packetList[element]) { | |
| return [...acc, element]; | |
| } | |
| return [...acc, ...sortDeps(packetList[element], packetList), element]; | |
| }, []); | |
| return keyRed; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const countSize = (node) => { | |
| return reduce((size, element) => { | |
| if (element.type === 'file') { | |
| return (size + element.meta.size); | |
| } | |
| return size; | |
| }, node, 0); | |
| }; | |
| export const sortDu = (array) => array.sort((prev, next) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const findFile = (node, fn, pathToFile) => { | |
| const pathElement = node.name; | |
| if (node.type === 'directory') { | |
| return node.children.reduce((res, element) => [...res, ...findFile(element, fn, path.join(pathToFile, pathElement))], []); | |
| } | |
| if (fn(node)) { | |
| return [path.join(pathToFile, node.name)]; | |
| } | |
| return []; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Enumerable { | |
| constructor(collection, operations) { | |
| this.collection = collection; | |
| this.operations = operations || []; | |
| } | |
| build(fn) { | |
| return new Enumerable(this.collection.slice(), this.operations.concat(fn)); | |
| } |
NewerOlder