# filename-sanitize

> sanitize file name to only have alphanumeric

Latest version **0.0.2** (published 2020-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install filename-sanitize
pnpm add filename-sanitize
yarn add filename-sanitize
bun add filename-sanitize
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-02-26 |
| First published | 2020-02-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | surya.iitg |
| Maintainers | surya.iitg |
| Keywords | filename, sanitize |

## Links

- npm: https://www.npmjs.com/package/filename-sanitize
- Repository: https://github.com/suryaiitg/filename-sanitize
- Homepage: https://github.com/suryaiitg/filename-sanitize#readme
- Issues: https://github.com/suryaiitg/filename-sanitize/issues
- npm.io page: https://npm.io/package/filename-sanitize

## Recent versions

- 0.0.2 (latest) — 2020-02-26
- 0.1.1 — 2020-02-11
- 0.0.1 — 2020-02-11

## README

# About

filename-sanitize : A filename sanitizer

Will take a filename and remove all special characters from it and change them to '_'

## Installation

filename-sanitize does not have any dependencies

npm i filename-sanitize --save

## Usage

By default it will add a timestamp to the filename
```javascript
  const sanitize = require('filename-sanitize');

  let filename = 'abc@def,ghi.zzz';
  filename = sanitize(filename);
  console.log(filename);
  //abc_def_ghi_1581418632712.zzz

```

## Options

options can be passed as second argument: an object with these key values

##timestamp: boolean

```javascript
  const sanitize = require('filename-sanitize');

  let filename = 'abc@def,ghi.zzz';
  filename = sanitize(filename, {
    timestamp: false
  });
  console.log(filename);
  //'abc_def_ghi.zzz'

```

##timestampValue: 12345 //Some number/string of your choice, default is current timestamp

```javascript
  const sanitize = require('filename-sanitize');

  let filename = 'abc@def,ghi.zzz';
  filename = sanitize(filename, {
    timestampValue: 12345
  });
  console.log(filename);
  //'abc_def_ghi_12345.zzz'

```

---
_Source: https://npm.io/package/filename-sanitize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
