
Security News
The Next Open Source Security Race: Triage at Machine Speed
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.
Map the destination path for a file based on the given source path and options.
Install with npm
$ npm i map-dest --save
var mapDest = require('map-dest');
(Table of contents generated by verb)
Returns an array when src is an array
mapDest(['a.txt', 'b.txt'], 'dist');
// [ { options: {}, src: 'a.txt', dest: 'dist/a.txt' },
// { options: {}, src: 'b.txt', dest: 'dist/b.txt' } ]
Creates a dest when no dest argument is passed.
mapDest('a/b/c.txt');
// [{ options: {}, src: 'a/b/c.txt', dest: 'a/b/c.txt' }]
When no dest is defined and src is an array, returns an array with generated dest paths.
mapDest(['a.txt', 'b.txt']);
// [ { options: {}, src: 'a.txt', dest: 'a.txt' },
// { options: {}, src: 'b.txt', dest: 'b.txt' } ]
Flattens dest when no dest argument is passed:
mapDest('a/b/c.txt', {flatten: true});
// [{ options: { flatten: true }, src: 'a/b/c.txt', dest: 'c.txt' }]
Replaces the destination extension with given ext:
mapDest('a/b/c.txt', {ext: '.foo'});
// [{ options: { ext: '.foo', extDot: 'first' },
// src: 'a/b/c.txt',
// dest: 'a/b/c.foo' }]
When cwd is defined it will be prepended to src:
mapDest('a/b/c.txt', {cwd: 'one/two'});
// [{ options: { cwd: 'one/two' },
// src: 'one/two/a/b/c.txt',
// dest: 'a/b/c.txt' }]
Prepends cwd to src and flattens dest:
mapDest('a/b/c.txt', {cwd: 'one/two', flatten: true});
// [{ options: { cwd: 'one/two', flatten: true },
// src: 'one/two/a/b/c.txt',
// dest: 'c.txt' }]
Expands tildes in cwd to make the path relative to the user's home directory:
mapDest('a/b/c.txt', {cwd: '~/one/two'});
// [{ options: { cwd: '/User/jonschlinkert/one/two', flatten: true },
// src: 'one/two/a/b/c.txt',
// dest: 'c.txt' }]
Expands @ in cwd to make the path relative to global npm modules:
mapDest('templates/base.hbs', {cwd: '@/boilerplate-h5bp'});
// [ { options: { cwd: '/usr/local/lib/node_modules/boilerplate-h5bp' },
// src: '/usr/local/lib/node_modules/boilerplate-h5bp/templates/base.hbs',
// dest: 'templates/base.hbs' } ]
If destBase is defined it's prepended to generated dest.
mapDest('a/b/c.txt', {destBase: 'one/two'});
// [{ options: { destBase: 'one/two' },
// src: 'a/b/c.txt',
// dest: 'one/two/a/b/c.txt' }]
If destBase is defined, it will be prepended to dest
mapDest('a/b/c.txt', 'foo', {destBase: 'one/two'});
// [{ options: { destBase: 'one/two' },
// src: 'a/b/c.txt',
// dest: 'one/two/foo/a/b/c.txt' }]
A custom rename function can be used to modify the generated dest path.
mapDest('a/b/c.md', {
rename: function (dest, src, opts) {
return 'dist/' + path.basename(src) + '.html';
}
});
// [{ options: { rename: [Function] },
// src: 'a/b/c.md',
// dest: 'dist/c.html' }]
-----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-----------|----------|----------|----------|----------|----------------|
map-dest/ | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
-----------|----------|----------|----------|----------|----------------|
All files | 100 | 100 | 100 | 100 | |
-----------|----------|----------|----------|----------|----------------|
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on September 03, 2015.
FAQs
Map the destination path for a file based on the given source path and options.
We found that map-dest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.

Security News
gem.coop is testing registry-level dependency cooldowns to limit exposure during the brief window when malicious gems are most likely to spread.