{"name":"filenamify","version":"7.0.2","keywords":["filename","safe","sanitize","file","name","string","path","filepath","convert","valid","dirname"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"filenamify@7.0.2","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/filenamify#readme","bugs":{"url":"https://github.com/sindresorhus/filenamify/issues"},"dist":{"shasum":"4a3ac9ffaebd7dc3bb649b4d28e3b9e8554fb12a","tarball":"http://registry-npm.ywwl.com/filenamify/download/filenamify-7.0.2.tgz","fileCount":9,"integrity":"sha512-fz10TUqSZ1lG7ftW1KnRotJzMD8YRb6kaAQKpZJBLvqXXfFgIEpuazy1w2lK3zhMiBSdH/uF9LFlv5smJ2Jl1w==","signatures":[{"sig":"MEUCIFRoHeAu+ia3jk5ZYZ8DwSa3MV29s36EGScTaGRycF8rAiEA0AS4bEMTESFU+KY336TypZAeVjZNuJd5GkfGjH5dG3c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12086,"size":4513,"noattachment":false,"key":"/filenamify/-/filenamify-7.0.2.tgz"},"type":"module","types":"./index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./index.d.ts","default":"./index.js"},"./browser":{"types":"./filenamify.d.ts","default":"./filenamify.js"}},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"4514bd1924e93dca9c444efee94a7776c4070bd8","scripts":{"test":"xo && ava"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/filenamify.git","type":"git"},"_npmVersion":"11.16.0","description":"Convert a string to a valid safe filename","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","dependencies":{"filename-reserved-regex":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^1.2.2","ava":"^6.4.1"},"_npmOperationalInternal":{"tmp":"tmp/filenamify_7.0.2_1781642801016_0.9802487494957928","host":"s3://npm-registry-packages-npm-production"},"readme":"# filenamify\n\n> Convert a string to a valid safe filename\n\nOn Unix-like systems, `/` is reserved. On Windows, [`<>:\"/\\|?*`](http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29#naming_conventions) along with trailing periods and spaces are reserved.\n\nThis module also removes non-printable control characters (including Unicode bidirectional marks) and normalizes Unicode whitespace.\n\n## Install\n\n```sh\nnpm install filenamify\n```\n\n## Usage\n\n```js\nimport filenamify from 'filenamify';\n\nfilenamify('<foo/bar>');\n//=> '!foo!bar!'\n\nfilenamify('foo:\"bar\"', {replacement: '🐴'});\n//=> 'foo🐴bar🐴'\n```\n\n## API\n\n### filenamify(string, options?)\n\nConvert a string to a valid filename.\n\n### filenamifyPath(path, options?)\n\nConvert the filename in a path to a valid filename and return the augmented path.\n\n```js\nimport {filenamifyPath} from 'filenamify';\n\nfilenamifyPath('foo:bar');\n//=> 'foo!bar'\n```\n\n#### options\n\nType: `object`\n\n##### replacement\n\nType: `string`\\\nDefault: `'!'`\n\nString to use as replacement for reserved filename characters.\n\nCannot contain: `<` `>` `:` `\"` `/` `\\` `|` `?` `*` or control characters.\n\nIf the replacement would leave the result as a Windows reserved name, `!` is used instead.\n\n##### maxLength\n\nType: `number`\\\nDefault: `100`\n\nTruncate the filename to the given length.\n\nOnly the base of the filename is truncated, preserving the extension. If the extension itself is longer than `maxLength`, you will get a string that is longer than `maxLength`, so you need to check for that if you allow arbitrary extensions.\n\nThe result may also exceed `maxLength` when a suffix is needed to avoid a Windows reserved name.\n\nTruncation is grapheme-aware and will not split Unicode characters (surrogate pairs or extended grapheme clusters). If the remaining budget (after accounting for the extension) is smaller than a whole grapheme, the base filename may be truncated to an empty string to avoid splitting.\n\nSystems generally allow up to 255 characters, but we default to 100 for usability reasons.\n\n## Browser-only import\n\nYou can also import `filenamify/browser`, which only imports `filenamify` and not `filenamifyPath`, which relies on `path` being available or polyfilled. Importing `filenamify` this way is therefore useful when it is shipped using `webpack` or similar tools, and if `filenamifyPath` is not needed.\n\n```js\nimport filenamify from 'filenamify/browser';\n\nfilenamify('<foo/bar>');\n//=> '!foo!bar!'\n```\n\n## Related\n\n- [filenamify-cli](https://github.com/sindresorhus/filenamify-cli) - CLI for this module\n- [filenamify-url](https://github.com/sindresorhus/filenamify-url) - Convert a URL to a valid filename\n- [valid-filename](https://github.com/sindresorhus/valid-filename) - Check if a string is a valid filename\n- [unused-filename](https://github.com/sindresorhus/unused-filename) - Get a unused filename by appending a number if it exists\n- [slugify](https://github.com/sindresorhus/slugify) - Slugify a string\n","publish_time":1781642801175,"_cnpm_publish_time":1781642801175,"dist-tags":{"latest":"7.0.3"}}