# protochain

> Get the prototype chain of any value as an Array

Latest version **1.0.5** (published 2016-06-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install protochain
pnpm add protochain
yarn add protochain
bun add protochain
```

## 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.0.5 |
| Published | 2016-06-30 |
| First published | 2015-03-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Tim Oxley |
| Maintainers | timoxley |
| Keywords | object, inherit, inheritance, prototypical, prototype, utility, proto, hierarchy, ancestors, grandparents, parents |

## Links

- npm: https://www.npmjs.com/package/protochain
- Repository: https://github.com/timoxley/protochain
- Issues: https://github.com/timoxley/protochain/issues
- npm.io page: https://npm.io/package/protochain

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2016-06-30
- 1.0.4 — 2016-06-30
- 1.0.3 — 2015-06-29
- 1.0.2 — 2015-03-07
- 1.0.1 — 2015-03-06
- 1.0.0 — 2015-03-06

## README

# protochain

### Get a value's prototype chain as an Array.

[![Build Status](https://travis-ci.org/timoxley/protochain.svg?branch=master)](https://travis-ci.org/timoxley/protochain)

[![NPM](https://nodei.co/npm/protochain.png?downloads=true&downloadRank=true)](https://nodei.co/npm-dl/protochain/)
[![NPM](https://nodei.co/npm-dl/protochain.png?months=3&height=3&chrome)](https://nodei.co/npm/protochain/)

## Installation

```
> npm install protochain
```

## Usage

```js
const protochain = require('protochain')
```

### Primitives

```js

protochain(123)
// => [Number.prototype, Object.prototype]

protochain('abc')
// => [String.prototype, Object.prototype]

protochain(/abc/)
// => [RegExp.prototype, Object.prototype]

protochain(true)
// => [Boolean.prototype, Object.prototype]

protochain(false)
// => [Boolean.prototype, Object.prototype]

protochain(NaN)
// => [Number.prototype, Object.prototype]
```

### Objects & null/undefined

```js
protochain({})
// => [Object.prototype]

protochain(Object.create(null))
// => []

protochain(null)
// => []

protochain(undefined)
// => []

protochain()
// => []
```

### Errors

```
protochain(new Error('message'))
// => [Error.prototype, Object.prototype]

protochain(new TypeError('message'))
// => [TypeError.prototype, Error.prototype, Object.prototype]
```

### Classes

```js
class Person {}
class FancyPerson extends Person {}

protochain(new Person())
// => [Person.prototype, Object.prototype]

protochain(new FancyPerson())
// => [FancyPerson.prototype, Person.prototype, Object.prototype])
```

### ES5 Inheritance

```js
function Person() {

}

function FancyPerson() {
  Person.call(this)
}

FancyPerson.prototype = Object.create(Person.prototype)

protochain(new Person())
// => [Person.prototype, Object.prototype]

protochain(new FancyPerson())
// => [FancyPerson.prototype, Person.prototype, Object.prototype]
```

### Promises

```js
protochain(Promise.resolve())
// => [Promise.prototype, Object.prototype]
```

### Collections

```js
protochain(new Map())
// => [Map.prototype, Object.prototype]

protochain(new Set())
// => [Set.prototype, Object.prototype]

protochain(new WeakMap())
// => [WeakMap.prototype, Object.prototype]

protochain(new WeakSet())
// => [WeakSet.prototype, Object.prototype]
```

### Typed Arrays

Note: different hierarchy in newer JS engines.

```js
protochain(new Int8Array())

// Newer Engines
// => [Int8Array.prototype, TypedArray.prototype, Object.prototype]

// Older Engines
// => [Int8Array.prototype, Object.prototype]
```

## License

MIT

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