# stc-helper

> Helper for stc

Latest version **1.0.7** (published 2018-09-26) · 0 weekly downloads

## Install

```sh
npm install stc-helper
pnpm add stc-helper
yarn add stc-helper
bun add stc-helper
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-09-26 |
| First published | 2016-06-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 1 |
| Unpacked size | 65.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | welefen |
| Maintainers | welefen |

## Links

- npm: https://www.npmjs.com/package/stc-helper
- Repository: https://github.com/stcjs/stc-helper
- Homepage: https://github.com/stcjs/stc-helper#readme
- Issues: https://github.com/stcjs/stc-helper/issues
- npm.io page: https://npm.io/package/stc-helper

## Dependencies (1)

- [babel-runtime](https://npm.io/package/babel-runtime.md) 6.x.x

## Recent versions

- 1.0.7 (latest) — 2018-09-26
- 1.0.6 — 2018-03-20
- 1.0.5 — 2016-11-04
- 1.0.4 — 2016-08-31
- 1.0.3 — 2016-08-15
- 1.0.1 — 2016-07-14
- 1.0.0 — 2016-06-15

## README

# stc-helper

[![NPM version](https://img.shields.io/npm/v/stc-helper.svg?style=flat-square)](http://badge.fury.io/js/stc-helper)
[![Build Status](https://travis-ci.org/stcjs/stc-helper.svg?branch=master)](https://travis-ci.org/stcjs/stc-helper)
[![Coverage Status](https://coveralls.io/repos/github/stcjs/stc-helper/badge.svg?branch=master&v=1)](https://coveralls.io/github/stcjs/stc-helper?branch=master)
[![Dependency Status](https://david-dm.org/stcjs/stc-helper.svg)](https://david-dm.org/stcjs/stc-helper)

helper for stc.

## Install

```
npm install stc-helper
```

## How to use

```js
import {isFile} from 'stc-helper';
if(isFile('xxx')){
  
}
```

## API

### isStream(stream)

check is stream.

```js
import {isStream} from 'stc-helper';
if(isStream(stream){
  
}
```

### isBuffer(buffer)

check is buffer.

```js
import {isBuffer} from 'stc-helper';
if(isBuffer(buf){
  
}
```

### isArray(arr)

check is array.

### isFunction(fn)

check is function.

### isObject(obj)

### isString(str)


### isRegExp(regexp)

check is RegExp.

### isExist(filePath)

check file/dir is exist.

### isFile(filepath)

### isDirectory(dir)


### extend(target, source)

deep copy

```js
let obj = extend({}, {name: 'stc'})
```

### getFiles(dir, prefix = '')

get files from dir.

```js
import {getFiles} from 'stc-helper';

let files = getFiles('/path/to'); // return is array

```

### promisify(fn, receiver)

make callback function to promise.

```js
import {promisify} from 'stc-helper';
import fs from 'fs'

let fn = promisify(fs.readFile, fs);
fn('/path/to/file', 'utf8').then(content => {
  
})
```

### defer()

get Deferred object.

```js
import {defer} from 'stc-helper';

let fn => {
  let deferred = defer();
  if(xxx){
    deferred.resolve('xxx');
  }else{
    deferred.reject(new Error());
  }
  return deferred.promise;
}

```

### md5(str)

get content md5 value.

### asyncReplace(content, replace, callback)

async content replace

```js
import {asyncReplace} from 'stc-helper';

let fn = async content => {
  return asyncReplace(content, /\d+/, (a, b) => {
    return Promise.resolve(a);
  });
}
```

### isRemoteUrl(url)

check is remote url

```js
isRemoteUrl('http://www.stcjs.org/'); //true
isRemoteUrl('https://www.stcjs.org/'); //true
isRemoteUrl('//www.stcjs.org/'); //true
```

### chmod(dir)

### mkdir(dir)

---
_Source: https://npm.io/package/stc-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
