https://github.com/igorskyflyer/npm-windev
🍃 Provides ways of checking whether a path is a legacy Windows device. 💾
https://github.com/igorskyflyer/npm-windev
back-end device file-system igorskyflyer javascript legacy nodejs npm path reserved storage string windows
Last synced: about 1 month ago
JSON representation
🍃 Provides ways of checking whether a path is a legacy Windows device. 💾
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-windev
- Owner: igorskyflyer
- License: mit
- Created: 2021-07-28T23:16:04.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-03T23:04:00.000Z (about 2 years ago)
- Last Synced: 2025-04-12T15:06:33.758Z (about 1 month ago)
- Topics: back-end, device, file-system, igorskyflyer, javascript, legacy, nodejs, npm, path, reserved, storage, string, windows
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@igor.dvlpr/windev
- Size: 229 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# \\\\.\\WinDev
🍃 Provides ways of checking whether a path is a legacy Windows device. 💾
> 💃 Since `v.1.1.0` this package provides both a CommonJS module and an ES module, thanks to [`Modern Module`](https://github.com/igorskyflyer/npm-modern-module).
>
> What do you need to do to use one or the other?
>
> Nothing. If you need a CommonJS module `require` it, if you need an ES module `import` it instead. Simple, right?
When creating files or folders on Windows there are some rules about naming them, one of which is that te usage of legacy Windows devices' names as the folder/file name is prohibited, i.e.:
> “Do not use the following reserved names for the name of a file:
>
> `CON`, `PRN`, `AUX`, `NUL`, `COM1`, `COM2`, `COM3`, `COM4`, `COM5`, `COM6`, `COM7`, `COM8`, `COM9`, `LPT1`, `LPT2`, `LPT3`, `LPT4`, `LPT5`, `LPT6`, `LPT7`, `LPT8`, and `LPT9`. Also avoid these names followed immediately by an extension; for example, `NUL.txt` is not recommended.”source: Microsot Docs
Be aware that there are some edge-cases that this module also handles, examples #4 and #7 illustrate that. Technically the provided strings in those two examples are not legacy devices but you are still not allowed to create files/directories with those names.
### Usage
Install it by running
```shell
npm i "@igor.dvlpr/windev"
```
### API
```ts
function isWindowsDevice(name: string) => boolean
```Checks whether the given directory or file name is a legacy Windows device.
### Examples
```js
const { isWindowsDevice } = require('@igor.dvlpr/windev')console.log(isWindowsDevice()) // prints false
console.log(isWindowsDevice('')) // prints false
console.log(isWindowsDevice('con')) // prints true
console.log(isWindowsDevice('con.txt')) // prints true
console.log(isWindowsDevice('cOm3')) // prints true
console.log(isWindowsDevice('COM7 ')) // prints true
console.log(isWindowsDevice(' COM2 .txt.al')) // prints true
console.log(isWindowsDevice('CONnection')) // prints false
```