Noncollinear Perpendicular Microcrystalline
Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

safename

1.0.2 • Public • Published

safename

Get safe file name from a given string.

Build Status

Example

// require only in node/browserify
var safename = require( 'safename' );
 
safename('my file name.txt');
// => my_file_name.txt
 
safename('my file name.txt', '-');
// => my-file-name.txt
 
safename.low('my file name.txt');
// => my_file_name.txt
 
safename.middle('my file name.txt');
// => my-file-name.txt
 
safename.dot('my file name.txt');
// => my.file.name.txt

Installation

Install with npm

$ npm install safename

Install with Bower

$ bower install safename

safename API

safename( name, space )

Get safe name for files

Parameters:

  • name String: string to transform
  • space String: replace for spaces. Optional, low dash ('_') by default
  • Return String: safe name

low( )

Safe name with low dash '_'.

Parameters:

Same as safename('your file name.txt', '_');

middle( )

Safe name with middle dash '-'.

Parameters:

Same as safename('your file name.txt', '-');

dot( )

Safe name with dots '.'.

Parameters:

Same as safename('your file name.txt', '.');

Tests

npm install && npm test

Build API docs

npm install && npm run build-docs




© 2014 jacoborus

Released under MIT License

install

npm i safename

Downloadsweekly downloads

1,902

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability