{"name":"filenamify","version":"7.0.1","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.1","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/filenamify#readme","bugs":{"url":"https://github.com/sindresorhus/filenamify/issues"},"dist":{"shasum":"aabe4f3fe93f8cd2a563fa367ff7f2bb98188c4c","tarball":"http://registry-npm.ywwl.com/filenamify/download/filenamify-7.0.1.tgz","fileCount":9,"integrity":"sha512-9b4rfnaX2MkJCgp27wypV6DAMvj4WMOSgJ+TdcpJIO84Dql+Cv6iJjdG4XDTLubOWkfNiBv3joO59sau/TXw+Q==","signatures":[{"sig":"MEUCIQD56wTUGyG4Vb3mbhSkGMtizEiSBRykifj5X6HI0GMYVgIgMkegJmKfT6x7hYRteHX+FimOQG0kgNvDTik2FxWHy+I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11719,"size":4449,"noattachment":false,"key":"/filenamify/-/filenamify-7.0.1.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":"5f4f97ce51825aa00afb0887a376e8e74be2e9b6","scripts":{"test":"xo && ava"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/filenamify.git","type":"git"},"_npmVersion":"11.6.1","description":"Convert a string to a valid safe filename","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","dependencies":{"filename-reserved-regex":"^4.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^1.2.2","ava":"^6.4.1"},"_npmOperationalInternal":{"tmp":"tmp/filenamify_7.0.1_1762358043477_0.11261015482563752","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":1762358043685,"_cnpm_publish_time":1762358043685,"dist-tags":{"latest":"7.0.3"}}