{"analyzedAt":"2022-07-13T10:24:59.560Z","collected":{"metadata":{"name":"@eit6609/walker","scope":"eit6609","version":"1.0.3","description":"A file and directory walker inspired by Python's os.walk()","keywords":["file","directory","python"],"date":"2019-11-27T15:44:36.547Z","publisher":{"username":"eit6609","email":"dario@morandini.org"},"maintainers":[{"username":"eit6609","email":"dario@morandini.org"}],"repository":{"type":"git","url":"git+https://github.com/eit6609/walker.git"},"links":{"npm":"https://www.npmjs.com/package/%40eit6609%2Fwalker","homepage":"https://github.com/eit6609/walker.git","repository":"https://github.com/eit6609/walker","bugs":"https://github.com/eit6609/walker/issues"},"license":"ISC","dependencies":{"bluebird":"^3.7.1","lodash":"^4.17.15"},"devDependencies":{"eslint":"^5.4.0","istanbul":"^1.1.0-alpha.1","jasmine":"^2.5.2","jasmine-core":"^2.5.2","jasmine-expect":"^3.6.0","jasmine-promises":"^0.4.1","jasmine-spec-reporter":"^3.2.0"},"releases":[{"from":"2022-06-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-04-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-01-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":1},{"from":"2021-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":1},{"from":"2020-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":1}],"hasTestScript":true,"readme":"# Walker\n\nWalker is a file system walker, i.e. it lets you traverse a directory recursively listing its files and sub-directories.\nIt was inspired by Python's [os.walk()](https://docs.python.org/3.6/library/os.html#os.walk).\n\nRun this to install:\n\n```bash\nnpm i @eit6609/walker\n```\n\n## Examples\n\nThere are two functions in walker, one synchronous and one asynchronous. The first is the direct translation of Python's\n`os.walk()`, while the latter is more in the Node mainstream. The choice is yours.\n\nThis is an example of `walk()`, the synchronous API:\n\n```js\nconst { walk } = require('@eit6609/walker');\n\nfor (const [dirPath, dirNames, fileNames] of walk('/path/to/dir')) {\n    console.log(`Members of ${dirPath}:`);\n    console.log('- directories:', dirNames);\n    console.log('- files:', fileNames);\n}\n```\n\nCompare it with its Python's equivalent:\n\n```python\nfrom os import walk;\n\nfor dirPath, dirNames, fileNames in walk('/path/to/dir'):\n    print('Members of {}:'.format(dirPath));\n    print('- directories:', dirNames);\n    print('- files:', fileNames);\n```\n\nThis is an example of `walkAsync()`, the asynchronous API:\n\n```js\nconst { walkAsync } = require('@eit6609/walker');\n\nfor (const promise of walkAsync('/path/to/dir')) {\n    const [dirPath, dirNames, fileNames] = await promise;\n    console.log(`Members of ${dirPath}:`);\n    console.log('- directories:', dirNames);\n    console.log('- files:', fileNames);\n}\n```\n\n## API Reference\n\n### `walk()`\n\n```js\nfunction walk(dirPath: string): iterator\n```\n\nIt takes a string with the path (absolute or relative) of the directory to scan.\n\nThe result is a JavaScript [iterator](https://developer.mozilla.org/it/docs/Web/JavaScript/Guide/Iterators_and_generators)\nwhich can be used in a `for...of` loop or \"unrolled\" to an array with `[...walk('/path/to/dir')]`.\n\nAt every step the iterator yields an array containing three items:\n\n* a string with the path of the directory\n* an array of strings with the names of the subdirectories\n* an array of strings with the names of the files\n\nThe arrays contain *names*. If you need the path of a file or a directory, you can build it using `path.join()`:\n\n```js\nconst\n    { join } = require('path'),\n    { walk } = require('@eit6609/walker');\n\nfor (const [dirPath, dirNames, fileNames] of walk('/path/to/dir')) {\n    for (let i = 0; i < fileNames.length; i++) {\n        console.log(join(dirPath, fileNames[i]));\n    }\n}\n```\n\nThis is the behaviour of the traversal:\n\n* it proceeds top down\n* it follows the symbolic links representing directories\n\nThe second item of the result, i.e. the array with the names of the directories, can be used to change the traversal,\nbecause it will be used in the next step of the iteration. This means that if you add or remove names to the array,\nor rearrange the names, the next step will behave differently. Quoting the docs of Python's `os.walk()`:\n\n>You can therefore prune the search, impose a specific order of visiting, or even inform walk() about directories the\n>caller creates or renames before it resumes walk() again.\n\n### `walkAsync()`\n\n```js\nfunction walkAsync(dirPath: string): promise of iterator\n```\n\nThe only difference with `walk()` is that the iterator yields a *promise* of the result, that needs to be resolved with\n`await` or `then()`.\n\nEnjoy!"},"npm":{"downloads":[{"from":"2022-07-12T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-07-06T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-06-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":11},{"from":"2022-04-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":52},{"from":"2022-01-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":135},{"from":"2021-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":330}],"starsCount":0},"github":{"starsCount":1,"forksCount":0,"subscribersCount":1,"issues":{"count":7,"openCount":4,"distribution":{"3600":0,"10800":0,"32400":0,"97200":1,"291600":0,"874800":0,"2624400":0,"7873200":0,"23619600":2,"70858800":4,"212576400":0},"isDisabled":false},"contributors":[{"username":"dependabot[bot]","commitsCount":1}],"commits":[{"from":"2022-07-06T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-06-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-04-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2022-01-14T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0},{"from":"2021-07-13T00:00:00.000Z","to":"2022-07-13T00:00:00.000Z","count":0}]},"source":{"files":{"readmeSize":3295,"testsSize":3170},"linters":["eslint"]}},"evaluation":{"quality":{"carefulness":0.84,"tests":0.6,"health":1,"branding":0},"popularity":{"communityInterest":3,"downloadsCount":17.333333333333332,"downloadsAcceleration":-0.17288812785388125,"dependentsCount":0},"maintenance":{"releasesFrequency":0.9,"commitsFrequency":0.9,"openIssues":0.9,"issuesDistribution":0.9}},"score":{"final":0.6062555541840313,"detail":{"quality":0.8262967790528932,"popularity":0.02402351023708409,"maintenance":0.9998808339576686}}}