Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/realpaths
Like fs.realpath, but resolves multiple paths at once
https://github.com/shinnn/realpaths
Last synced: 27 days ago
JSON representation
Like fs.realpath, but resolves multiple paths at once
- Host: GitHub
- URL: https://github.com/shinnn/realpaths
- Owner: shinnn
- License: isc
- Created: 2015-11-07T08:41:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-06T11:42:22.000Z (about 7 years ago)
- Last Synced: 2024-04-23T23:14:45.525Z (7 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# realpaths
[![npm version](https://img.shields.io/npm/v/realpaths.svg)](https://www.npmjs.com/package/realpaths)
[![Build Status](https://travis-ci.org/shinnn/realpaths.svg?branch=master)](https://travis-ci.org/shinnn/realpaths)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/realpaths.svg)](https://coveralls.io/github/shinnn/realpaths)Like [fs.realpath][realpath], but resolves multiple paths at once
```javascript
const realpaths = require('realpaths');// symlink1 <<===>> /path/to/foo.txt
// symlink2 <<===>> /path/to/bar.txt(async () => {
await realpaths(['symlink1', 'symlink2']) //=> ['/path/to/foo.txt', '/path/to/bar.txt']
})();
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install realpaths
```## API
```javascript
const realpaths = require('realpaths');
```### realpaths(*paths* [, *cache*])
*paths*: `Array` (file paths)
*options*: `Object` (used as [`fs.realpath`](https://github.com/nodejs/node/blob/c339fa36f5493c2bd2e108463910122ef82843c4/lib/fs.js#L1568-L1570) cache)
Return: `Promise>`It runs [`fs.realpath`][realpath] for each path and returns a `Promise` instance.
When it finishes resolving all paths, it will be [fulfilled](https://promisesaplus.com/#point-26) with an array of resolved paths.
```javascript
const {resolve} = require('path');
const realpaths = require('realpaths-callback');realpaths(['symlink1', 'symlink2'], {
cache: {
[resolve('symlink1')]: '/path/to/foo.txt',
[resolve('symlink2')]: '/path/to/bar.txt'
}
}).then(paths => {
paths; //=> ['/path/to/foo.txt', '/path/to/bar.txt']
});
```## Related projects
* [realpaths-callback](https://github.com/shinnn/realpaths-callback) – [Callback](http://thenodeway.io/posts/understanding-error-first-callbacks/)-style version
## License
[ISC License](./LICENSE) © 2017 Shinnosuke Watanabe
[realpath]: https://nodejs.org/api/fs.html#fs_fs_realpath_path_options_callback