### Installing filenamify Package (npm) Source: https://github.com/sindresorhus/filenamify/blob/main/readme.md This snippet demonstrates how to install the `filenamify` package using npm, the Node.js package manager. This command adds the package to your project's `node_modules` directory and updates your `package.json` file, making it available for use in your JavaScript applications. ```sh npm install filenamify ``` -------------------------------- ### Converting Strings to Filenames with filenamify (JavaScript) Source: https://github.com/sindresorhus/filenamify/blob/main/readme.md This JavaScript snippet shows basic usage of the `filenamify` function. It imports the function and demonstrates converting a string with reserved characters (``) to a safe filename, replacing them with `!`. It also illustrates using the `replacement` option to specify a custom character (🐴) for substitution. ```js import filenamify from 'filenamify'; filenamify(''); //=> '!foo!bar!' filenamify('foo:"bar"', {replacement: '🐴'}); //=> 'foo🐴bar🐴' ``` -------------------------------- ### Importing filenamify for Browser Environments (JavaScript) Source: https://github.com/sindresorhus/filenamify/blob/main/readme.md This JavaScript snippet shows how to import the browser-specific version of `filenamify` using `filenamify/browser`. This import is optimized for browser environments, as it excludes `filenamifyPath` which depends on Node.js's `path` module. It performs the same string conversion as the standard import, replacing reserved characters with `!`. ```js import filenamify from 'filenamify/browser'; filenamify(''); //=> '!foo!bar!' ``` -------------------------------- ### Converting Filenames in Paths with filenamifyPath (JavaScript) Source: https://github.com/sindresorhus/filenamify/blob/main/readme.md This snippet demonstrates how to use the `filenamifyPath` function from the `filenamify` library. This function specifically converts the filename part of a given path string into a valid filename, leaving the directory structure intact. It's useful when you need to sanitize only the base name of a file within a full path. ```js import {filenamifyPath} from 'filenamify'; filenamifyPath('foo:bar'); //=> 'foo!bar' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.