Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/realpaths-callback
Callback-style version of realpaths
https://github.com/shinnn/realpaths-callback
Last synced: 27 days ago
JSON representation
Callback-style version of realpaths
- Host: GitHub
- URL: https://github.com/shinnn/realpaths-callback
- Owner: shinnn
- License: mit
- Created: 2015-11-03T05:58:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-21T01:50:22.000Z (over 8 years ago)
- Last Synced: 2024-09-25T20:51:07.238Z (about 2 months ago)
- Language: JavaScript
- Homepage: https://github.com/shinnn/realpaths
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# realpaths-callback
[![NPM version](https://img.shields.io/npm/v/realpaths-callback.svg)](https://www.npmjs.com/package/realpaths-callback)
[![Build Status](https://travis-ci.org/shinnn/realpaths-callback.svg?branch=master)](https://travis-ci.org/shinnn/realpaths-callback)
[![Build status](https://ci.appveyor.com/api/projects/status/faycw72q6pw3inrd/branch/master?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/realpaths-callback/branch/master)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/realpaths-callback.svg)](https://coveralls.io/r/shinnn/realpaths-callback)
[![Dependency Status](https://david-dm.org/shinnn/realpaths-callback.svg)](https://david-dm.org/shinnn/realpaths-callback)
[![devDependency Status](https://david-dm.org/shinnn/realpaths-callback/dev-status.svg)](https://david-dm.org/shinnn/realpaths-callback#info=devDependencies)[Callback](http://thenodeway.io/posts/understanding-error-first-callbacks/)-style version of [realpaths](https://www.npmjs.com/package/realpaths):
> Like [fs.realpath][realpath], but resolves multiple paths at once
```javascript
const realpathsCallback = require('realpaths-callback');// symlink1 <<===>> /path/to/foo.txt
// symlink2 <<===>> /path/to/bar.txtrealpaths(['symlink1', 'symlink2'], (err, paths) => {
if (err) {
throw err;
}paths; //=> ['/path/to/foo.txt', '/path/to/bar.txt']
});
```## Installation
[Use npm.](https://docs.npmjs.com/cli/install)
```
npm install realpaths-callback
```## API
```javascript
const realpathsCallback = require('realpaths-callback');
```### realpathsCallback(*paths* [, *cache*], *callback*)
*paths*: `Array` of strings (file paths)
*cache*: `Object` (used as [`fs.realpath`](https://github.com/nodejs/node/blob/c339fa36f5493c2bd2e108463910122ef82843c4/lib/fs.js#L1568-L1570) cache)
*callback*: `Function` (called after the paths are resolved)It's API is very similar to [`fs.realpath`][realpath]. The only difference is *realpaths-callback* takes an array as its first argument and resolves multiple paths at once.
```javascript
'use strict';const path = require('path');
const realpaths = require('realpaths-callback');realpaths(['symlink1', 'symlink2'], {
cache: {
[path.resolve('symlink1')]: '/path/to/foo.txt',
[path.resolve('symlink2')]: '/path/to/bar.txt'
}
}, (err, paths) => {
if (err) {
throw err;
}
paths; //=> ['/path/to/foo.txt', '/path/to/bar.txt']
});
```If at least one of the paths cannot be resolved, it immediately passes an error to its callback function without considering the rest of paths.
## Related project
* [realpaths](https://github.com/shinnn/realpaths) ([Promises/A+](https://promisesaplus.com/) version)
## License
Copyright (c) 2015 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).
[realpath]: https://nodejs.org/api/fs.html#fs_fs_realpath_path_cache_callback