Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
add some docs about require/import/typing (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Sep 25, 2017
1 parent ef7c298 commit fad95fd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ LevelUP
* <a href="#basic">Basic usage</a>
* <a href="#api">API</a>
* <a href="#promises">Promise Support</a>
* <a href="#import">Import with Type Definitions</a>
* <a href="#events">Events</a>
* <a href="#extending">Extending LevelUP</a>
* <a href="#multiproc">Multi-process access</a>
Expand Down Expand Up @@ -452,6 +453,36 @@ const main = async () {

--------------------------------------------------------

<a name="import"></a>
ES6 Import and Typing(for TypeScript)
-------------------------------------

We have two ways to import(require) the levelup module in the code.

### 1. The old fashioned `require`

```js
var levelup = require('levelup')
```

### 2. The new ES6 `import`

```js
import levelup from 'levelup'
```

## TypeScript

LevelUp ships with TypeScript `type definitions` support out-of-box. So we can use `import` with Type Defination by default.

The benefits will be:
1. [Static Type Checking](http://2ality.com/2014/10/typed-javascript.html)
1. [IDE IntelliSense](https://code.visualstudio.com/docs/editor/intellisense)

Recommended IDE: [Visual Studio Code](https://code.visualstudio.com/)

--------------------------------------------------------

<a name="events"></a>
Events
------
Expand Down

0 comments on commit fad95fd

Please sign in to comment.