first commit
This commit is contained in:
24
app_vue/node_modules/totalist/dist/index.js
generated
vendored
Normal file
24
app_vue/node_modules/totalist/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
const { join, resolve } = require('path');
|
||||
const { readdir, stat } = require('fs');
|
||||
const { promisify } = require('util');
|
||||
|
||||
const toStats = promisify(stat);
|
||||
const toRead = promisify(readdir);
|
||||
|
||||
async function totalist(dir, callback, pre='') {
|
||||
dir = resolve('.', dir);
|
||||
await toRead(dir).then(arr => {
|
||||
return Promise.all(
|
||||
arr.map(str => {
|
||||
let abs = join(dir, str);
|
||||
return toStats(abs).then(stats => {
|
||||
return stats.isDirectory()
|
||||
? totalist(abs, callback, join(pre, str))
|
||||
: callback(join(pre, str), abs, stats)
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
exports.totalist = totalist;
|
22
app_vue/node_modules/totalist/dist/index.mjs
generated
vendored
Normal file
22
app_vue/node_modules/totalist/dist/index.mjs
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import { join, resolve } from 'path';
|
||||
import { readdir, stat } from 'fs';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const toStats = promisify(stat);
|
||||
const toRead = promisify(readdir);
|
||||
|
||||
export async function totalist(dir, callback, pre='') {
|
||||
dir = resolve('.', dir);
|
||||
await toRead(dir).then(arr => {
|
||||
return Promise.all(
|
||||
arr.map(str => {
|
||||
let abs = join(dir, str);
|
||||
return toStats(abs).then(stats => {
|
||||
return stats.isDirectory()
|
||||
? totalist(abs, callback, join(pre, str))
|
||||
: callback(join(pre, str), abs, stats)
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
3
app_vue/node_modules/totalist/index.d.ts
generated
vendored
Normal file
3
app_vue/node_modules/totalist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Stats } from 'fs';
|
||||
export type Caller = (relPath: string, absPath: string, stats: Stats) => any;
|
||||
export function totalist(dir: string, callback: Caller, prefix?: string): Promise<void>;
|
21
app_vue/node_modules/totalist/license
generated
vendored
Normal file
21
app_vue/node_modules/totalist/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
55
app_vue/node_modules/totalist/package.json
generated
vendored
Normal file
55
app_vue/node_modules/totalist/package.json
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "totalist",
|
||||
"version": "3.0.1",
|
||||
"repository": "lukeed/totalist",
|
||||
"description": "A tiny (195B to 220B) utility to recursively list all (total) files in a directory",
|
||||
"module": "dist/index.mjs",
|
||||
"main": "dist/index.js",
|
||||
"types": "index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"./sync": {
|
||||
"types": "./sync/index.d.ts",
|
||||
"import": "./sync/index.mjs",
|
||||
"require": "./sync/index.js"
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dist",
|
||||
"sync"
|
||||
],
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke.edwards05@gmail.com",
|
||||
"url": "https://lukeed.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"keywords": [
|
||||
"list",
|
||||
"recursive",
|
||||
"files",
|
||||
"glob",
|
||||
"tree"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "bundt",
|
||||
"test": "uvu -r esm test -i fixtures"
|
||||
},
|
||||
"modes": {
|
||||
"sync": "src/sync.js",
|
||||
"default": "src/async.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bundt": "1.1.1",
|
||||
"esm": "3.2.25",
|
||||
"uvu": "0.3.3"
|
||||
}
|
||||
}
|
109
app_vue/node_modules/totalist/readme.md
generated
vendored
Normal file
109
app_vue/node_modules/totalist/readme.md
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
# totalist [](https://github.com/lukeed/totalist/actions) [](https://codecov.io/gh/lukeed/totalist)
|
||||
|
||||
> A tiny (195B to 224B) utility to recursively list all (total) files in a directory
|
||||
|
||||
Traverse a directory recursively, running a function for **every file** found.
|
||||
|
||||
With this module, you easily apply custom logic to decide which file(s) to process without worrying about accidentally accessing a directory or making repeat `fs.Stats` requests.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save totalist
|
||||
```
|
||||
|
||||
|
||||
## Modes
|
||||
|
||||
There are two "versions" of `totalist` available:
|
||||
|
||||
#### "async"
|
||||
> **Node.js:** >= 8.x<br>
|
||||
> **Size (gzip):** 220 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/totalist/dist/index.js), [ES Module](https://unpkg.com/totalist/dist/index.mjs)
|
||||
|
||||
This is the primary/default mode. It makes use of `async`/`await` and [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original).
|
||||
|
||||
#### "sync"
|
||||
> **Node.js:** >= 6.x<br>
|
||||
> **Size (gzip):** 195 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/totalist/sync/index.js), [ES Module](https://unpkg.com/totalist/sync/index.mjs)
|
||||
|
||||
This is the opt-in mode, ideal for scenarios where `async` usage cannot be supported.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
***Selecting a Mode***
|
||||
|
||||
```js
|
||||
// import via npm module
|
||||
import { totalist } from 'totalist';
|
||||
import { totalist } from 'totalist/sync';
|
||||
```
|
||||
|
||||
***Example Usage***
|
||||
|
||||
```js
|
||||
import { totalist } from 'totalist/sync';
|
||||
|
||||
const styles = new Set();
|
||||
const scripts = new Set();
|
||||
|
||||
totalist('src', (name, abs, stats) => {
|
||||
if (/\.js$/.test(name)) {
|
||||
scripts.add(abs);
|
||||
if (stats.size >= 100e3) {
|
||||
console.warn(`[WARN] "${name}" might cause performance issues (${stats.size})`);
|
||||
}
|
||||
} else if (/\.css$/.test(name)) {
|
||||
styles.add(abs);
|
||||
}
|
||||
});
|
||||
|
||||
console.log([...scripts]);
|
||||
//=> [..., '/Users/lukeed/.../src/path/to/example.css', ...]
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### totalist(dir, callback)
|
||||
Returns: `void`
|
||||
|
||||
> **Important:** The "async" usage must be `await`ed or included within a Promise chain.
|
||||
|
||||
#### dir
|
||||
Type: `string`<br>
|
||||
Required: `true`
|
||||
|
||||
The directory to traverse.
|
||||
|
||||
This may be a relative _or_ an absolute path.
|
||||
|
||||
> **Note**: Node.js will assume a relative path is meant to be resolved from the current location (`process.cwd()`).
|
||||
|
||||
#### callback
|
||||
Type: `Function`<br>
|
||||
Required: `true`
|
||||
|
||||
The callback function to run for _every_ file.
|
||||
|
||||
The function receives three parameters:
|
||||
|
||||
##### relPath
|
||||
Type: `String`<br>
|
||||
The path _relative to_ the initial `dir` value you provided.
|
||||
|
||||
##### absPath
|
||||
Type: `String`<br>
|
||||
The absolute path of the file.
|
||||
|
||||
##### stats
|
||||
Type: `fs.Stats`<br>
|
||||
The [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object for the file.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
3
app_vue/node_modules/totalist/sync/index.d.ts
generated
vendored
Normal file
3
app_vue/node_modules/totalist/sync/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Stats } from 'fs';
|
||||
export type Caller = (relPath: string, absPath: string, stats: Stats) => any;
|
||||
export function totalist(dir: string, callback: Caller, prefix?: string): void;
|
17
app_vue/node_modules/totalist/sync/index.js
generated
vendored
Normal file
17
app_vue/node_modules/totalist/sync/index.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
const { join, resolve } = require('path');
|
||||
const { readdirSync, statSync } = require('fs');
|
||||
|
||||
function totalist(dir, callback, pre='') {
|
||||
dir = resolve('.', dir);
|
||||
let arr = readdirSync(dir);
|
||||
let i=0, abs, stats;
|
||||
for (; i < arr.length; i++) {
|
||||
abs = join(dir, arr[i]);
|
||||
stats = statSync(abs);
|
||||
stats.isDirectory()
|
||||
? totalist(abs, callback, join(pre, arr[i]))
|
||||
: callback(join(pre, arr[i]), abs, stats);
|
||||
}
|
||||
}
|
||||
|
||||
exports.totalist = totalist;
|
15
app_vue/node_modules/totalist/sync/index.mjs
generated
vendored
Normal file
15
app_vue/node_modules/totalist/sync/index.mjs
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import { join, resolve } from 'path';
|
||||
import { readdirSync, statSync } from 'fs';
|
||||
|
||||
export function totalist(dir, callback, pre='') {
|
||||
dir = resolve('.', dir);
|
||||
let arr = readdirSync(dir);
|
||||
let i=0, abs, stats;
|
||||
for (; i < arr.length; i++) {
|
||||
abs = join(dir, arr[i]);
|
||||
stats = statSync(abs);
|
||||
stats.isDirectory()
|
||||
? totalist(abs, callback, join(pre, arr[i]))
|
||||
: callback(join(pre, arr[i]), abs, stats);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user