# nano-seconds

> Get the nano seconds of current time

Latest version **1.2.2** (published 2017-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install nano-seconds
pnpm add nano-seconds
yarn add nano-seconds
bun add nano-seconds
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2017-09-15 |
| First published | 2017-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Tree Xie |
| Maintainers | tree.xie |
| Keywords | nanoseconds, nano-seconds, nano |

## Links

- npm: https://www.npmjs.com/package/nano-seconds
- Repository: https://github.com/vicanso/nano-seconds
- Homepage: https://github.com/vicanso/nano-seconds#readme
- Issues: https://github.com/vicanso/nano-seconds/issues
- npm.io page: https://npm.io/package/nano-seconds

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2017-09-15
- 1.2.1 — 2017-06-22
- 1.2.0 — 2017-06-01
- 1.1.0 — 2017-04-17
- 1.0.0 — 2017-03-07

## README

# nano-seconds

Get the nano seconds of now

[![Build Status](https://travis-ci.org/vicanso/nano-seconds.svg?style=flat-square)](https://travis-ci.org/vicanso/nano-seconds)
[![Coverage Status](https://img.shields.io/coveralls/vicanso/nano-seconds/master.svg?style=flat)](https://coveralls.io/r/vicanso/nano-seconds?branch=master)
[![npm](http://img.shields.io/npm/v/nano-seconds.svg?style=flat-square)](https://www.npmjs.org/package/nano-seconds)
[![Github Releases](https://img.shields.io/npm/dm/nano-seconds.svg?style=flat-square)](https://github.com/vicanso/nano-seconds)

## Installation

```bash
$ npm install nano-seconds
```

## API

### now

Get the nano seconds of current time, it will return [seconds, nanos]

```js
const nano = require('nano-seconds');
// [ 1488895112, 951851969 ]
console.info(nano.now());
```

### toString

Format the nano seconds to string

- `ns` if not set the param, it will be `nano.now()`

```js
const nano = require('nano-seconds');
const ns = nano.now();
// [ 1488895353, 21164240 ]
console.info(ns);
// 1488895353021164240
console.info(nano.toString(ns));
// 1488895353025439741
console.info(nano.toString());
```

### toISOString

Format the nano seconds to ISOString

- `ns` if not set the param, it will be `nano.now()`

```js
const nano = require('nano-seconds');
const ns = nano.now();
// 2017-06-22T14:37:42.506635539Z
console.info(nano.toISOString(ns));
// 2017-06-22T14:37:42.5069231Z
console.info(nano.toISOString());
```

### fromISOString

Get the nano from ISOString

- `iosFormat` ISO Date String

```js
const nano = require('nano-seconds');
const arr = nano.fromISOString(str);
// [ 1505477440, 922020280 ]
console.info(arr);
```


### difference

Get the difference of two nano seconds, ns2 - ns1

- `ns1` The start nano seconds

- `ns2` The end nano seconds, default is `nano.now()`

```js
const ns = nano.now();
setTimeout(() => {
  const diff = nano.difference(ns);
  // 102661874
  console.info(diff);
}, 100);
```


## License

MIT

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