Added vscode settings

This commit is contained in:
Kristofers Solo
2022-04-28 20:54:44 +03:00
parent 245c3ca779
commit 837a479d82
25004 changed files with 2499800 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
'use strict';
const fileType = require('file-type');
const isStream = require('is-stream');
const tarStream = require('tar-stream');
module.exports = () => input => {
if (!Buffer.isBuffer(input) && !isStream(input)) {
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
}
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'tar')) {
return Promise.resolve([]);
}
const extract = tarStream.extract();
const files = [];
extract.on('entry', (header, stream, cb) => {
const chunk = [];
stream.on('data', data => chunk.push(data));
stream.on('end', () => {
const file = {
data: Buffer.concat(chunk),
mode: header.mode,
mtime: header.mtime,
path: header.name,
type: header.type
};
if (header.type === 'symlink' || header.type === 'link') {
file.linkname = header.linkname;
}
files.push(file);
cb();
});
});
const promise = new Promise((resolve, reject) => {
if (!Buffer.isBuffer(input)) {
input.on('error', reject);
}
extract.on('finish', () => resolve(files));
extract.on('error', reject);
});
extract.then = promise.then.bind(promise);
extract.catch = promise.catch.bind(promise);
if (Buffer.isBuffer(input)) {
extract.end(input);
} else {
input.pipe(extract);
}
return extract;
};

View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva)
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.

View File

@@ -0,0 +1,38 @@
{
"name": "decompress-tar",
"version": "4.1.1",
"description": "decompress tar plugin",
"license": "MIT",
"repository": "kevva/decompress-tar",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "https://github.com/kevva"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"decompress",
"decompressplugin",
"extract",
"tar"
],
"dependencies": {
"file-type": "^5.2.0",
"is-stream": "^1.1.0",
"tar-stream": "^1.5.2"
},
"devDependencies": {
"ava": "*",
"is-jpg": "^1.0.0",
"pify": "^3.0.0",
"xo": "*"
}
}

View File

@@ -0,0 +1,44 @@
# decompress-tar [![Build Status](https://travis-ci.org/kevva/decompress-tar.svg?branch=master)](https://travis-ci.org/kevva/decompress-tar)
> tar decompress plugin
## Install
```
$ npm install decompress-tar
```
## Usage
```js
const decompress = require('decompress');
const decompressTar = require('decompress-tar');
decompress('unicorn.tar', 'dist', {
plugins: [
decompressTar()
]
}).then(() => {
console.log('Files decompressed');
});
```
## API
### decompressTar()(input)
Returns both a Promise for a Buffer and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
#### input
Type: `Buffer` `Stream`
Buffer or stream to decompress.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)