Callback-style version of realpaths:
Like fs.realpath, but resolves multiple paths at once
const realpathsCallback = require('realpaths-callback');
// symlink1 <<===>> /path/to/foo.txt
// symlink2 <<===>> /path/to/bar.txt
realpaths(['symlink1', 'symlink2'], (err, paths) => {
if (err) {
throw err;
}
paths; //=> ['/path/to/foo.txt', '/path/to/bar.txt']
});
npm install realpaths-callback
const realpathsCallback = require('realpaths-callback');
paths: Array
of strings (file paths)
cache: Object
(used as fs.realpath
cache)
callback: Function
(called after the paths are resolved)
It's API is very similar to fs.realpath
. The only difference is realpaths-callback takes an array as its first argument and resolves multiple paths at once.
'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.
- realpaths (Promises/A+ version)
Copyright (c) 2015 - 2016 Shinnosuke Watanabe
Licensed under the MIT License.