open-index/open-npm huggingface dataset:
npm package: @peregrine/exceptions
Description: Library containing errors for HTTP, FileSystem operations and more
Author: Marc
Latest version: 0.2.0
Deprecated: This package is no longer supported by its developer

# @peregrine/exceptions
Library containing errors for HTTP, FileSystem operations and more

## Setup
`npm install --save @peregrine/exceptions`

## Examples
```JavaScript
import { http } from "@peregrine/exceptions"
/**
 * const exceptions = require("@peregrine/exceptions")
 * const http = exceptions.http
 */

express.use('/api/v2/users/@me', (request, response, next) => {
    next(new http.NotImplemented501Error("This endpoint is not implemented yet."))
})

this.express.use('*', (request, response, next) => {
    next(new http.NotFound404Error('This endpoint does not exist.'))
})

express.use((error, request, response, next) => {
    res.status(error.code || 500).json(error))
})
```

```TypeScript
import { StringIndexOutOfBoundsException } from "@peregrine/exceptions"

export function getUppercasedCharacter(str: string, index: number){
    if(index < 0 || index > str.length - 1){
        throw new StringIndexOutOfBoundsException(`Index ${index} is ${index < 0 ? "smaller" : "greater"} than allowed: should be between 0 and ${str.length - 1}`)
    }

    return str.charAt(index).toUpperCase()
}
```

```TypeScript
import { StringIndexOutOfBoundsException } from "@peregrine/exceptions"

export function getUppercasedCharacter(str: string, index: number){
    if(index < 0 || index > str.length - 1){
        throw new StringIndexOutOfBoundsException(`Index ${index} is ${index < 0 ? "smaller" : "greater"} than allowed: should be between 0 and ${str.length - 1}`)
    }

    return str.charAt(index).toUpperCase()
}
```

```TypeScript
import { MethodNotImplementedException } from "@peregrine/exceptions"

export class WIPclass {
    doSomething(): string | number {
        throw new MethodNotImplementedException()
    }
}
```
npm package: @peregrine/filesystem
Description: Simple FileSystem API for NodeJS, with Promise and Stream support
Author: Marc
Latest version: 0.4.0-alpha.1
Deprecated: This package is no longer supported by its developer

# @peregrine/filesystem
Simple FileSystem API for NodeJS, with Promise and Stream support.

## Code example
### Files
**printInfo.ts**
```TypeScript
import { Directory, File } from "@peregrine/filesystem"

export default async function printInfo(item: Directory | File){
    // Print directory or file info
    console.log(`Path: ${item.path}\n`)
    console.log(`Name: ${item.name}\n`)
    console.log(`Type: ${item instanceof Directory ? "Directory" : "File"}\n\n`)

    if(item instanceof Directory){
        // Print all the children
        let items = (await item.children).map(item => `  - ${item.name} (${item instanceof Directory ? "Directory" : "File"})`)
        console.log(`Children:\n${items.join("\n")}`)
    }
}
```

**example1.ts**
```TypeScript
import { Directory, File } from "@peregrine/filesystem"
import printInfo from "./printInfo"

// Get current directory
const currentDir = Directory.currentDir

// Get parent directory
const parentDir = currentDir.parent

// The parent can be null if there's no parent directory (C:/ does not have any parent directory)
if(parentDir != null) printInfo(parentDir)
```

**example2.ts**
```TypeScript
import { Directory, File } from "@peregrine/filesystem"
import printInfo from "./printInfo"

(async() => {
    const file = await File.createItem(`C:/Users/Someone/Documents/test.docx`)
    if(file != null) printInfo(file)
})()
```
  
### Output
**example1.ts**  
```
Path: C:/Users/Someone/Documents
Name: Documents
Type: Directory

Children:
  - test.docx (File)
  - CloudStorage (Directory)
  - test.txt (File)
```

**example2.ts**  
```
Path: C:/Users/Someone/Documents/test.docx
Name: test.docx
Type: File
```