Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dex4er/js-fs.mkdir-shim

Polyfill for fs.mkdir in node versions < v10.12
https://github.com/dex4er/js-fs.mkdir-shim

hacktoberfest

Last synced: about 2 months ago
JSON representation

Polyfill for fs.mkdir in node versions < v10.12

Awesome Lists containing this project

README

        

# fs.mkdir-shim

[![Build Status](https://secure.travis-ci.org/dex4er/js-fs.mkdir-shim.svg)](http://travis-ci.org/dex4er/js-fs.mkdir-shim) [![npm](https://img.shields.io/npm/v/fs.mkdir-shim.svg)](https://www.npmjs.com/package/fs.mkdir-shim)

Polyfill for fs.mkdir in node versions < v10.12

node v10.12.0 added support for a recursive option for `fs.mkdir`:

This package provides the built-in `fs.mkdir` in node v10.12.0 and later,
and a replacement in other environments.

The replacement uses [`make-dir`](https://www.npmjs.com/package/make-dir)
module.

## Requirements

This module requires Node >= 6.

This package implements the [es-shim API](https://github.com/es-shims/api)
interface. It works in an ES6-supported environment and complies with the
[spec](http://www.ecma-international.org/ecma-262/6.0/).

## Installation

```shell
npm install fs.mkdir-shim
```

_Additionally for Typescript:_

```shell
npm install -D @types/node
```

## Usage

### Direct

```js
const mkdir = require('fs.mkdir-shim');
// Use `mkdir` just like the built-in method on `fs`
```

_Typescript:_

```ts
import mkdir from 'fs.mkdir-shim';
// Use `mkdir` just like the built-in method on `fs`
```

### Shim

```js
require('fs.mkdir-shim/shim')();
// `fs.mkdir` is now defined
const fs = require('fs');
// Use `fs.mkdir`
```

or:

```js
require('fs.mkdir-shim/auto');
// `fs.mkdir` is now defined
const fs = require('fs');
// Use `fs.mkdir`
```

_Typescript:_

```js
import mkdirShim from 'fs.mkdir-shim/shim';
mkdirShim();
// `fs.mkdir` is now defined
import fs from 'fs';
// Use `fs.mkdir`
```

or:

```js
import 'fs.mkdir-shim/auto';
// `fs.mkdir` is now defined
import fs from 'fs';
// Use `fs.mkdir`
```

## License

Copyright (c) 2018-2020 Piotr Roszatycki

[MIT](https://opensource.org/licenses/MIT)