# toposort-extended

> toposort with objects

Latest version **1.0.1** (published 2015-06-29) · 0 weekly downloads

## Install

```sh
npm install toposort-extended
pnpm add toposort-extended
yarn add toposort-extended
bun add toposort-extended
```

## 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.1 |
| Published | 2015-06-29 |
| First published | 2014-10-26 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Overlook Motel |
| Maintainers | overlookmotel |
| Keywords | topological, sort, sorting, graphs, graph, dependency, list, dependencies, acyclic, object |

## Links

- npm: https://www.npmjs.com/package/toposort-extended
- Repository: https://github.com/overlookmotel/toposort-extended
- Issues: https://github.com/overlookmotel/toposort-extended/issues
- npm.io page: https://npm.io/package/toposort-extended

## Dependencies (1)

- [toposort](https://npm.io/package/toposort.md) 0.2.10

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-06-29
- 1.0.0 — 2015-05-27
- 0.1.3 — 2015-05-06
- 0.1.2 — 2014-10-28
- 0.1.1 — 2014-10-28
- 0.1.0 — 2014-10-26

## README

# toposort-extended.js

# toposort with objects

## What it does

An extension of [toposort](https://github.com/marcelklehr/toposort) where the inputs can be objects.

## Current status

[![NPM version](https://img.shields.io/npm/v/toposort-extended.svg)](https://www.npmjs.com/package/toposort-extended)
[![Build Status](https://img.shields.io/travis/overlookmotel/toposort-extended/master.svg)](http://travis-ci.org/overlookmotel/toposort-extended)
[![Dependency Status](https://img.shields.io/david/overlookmotel/toposort-extended.svg)](https://david-dm.org/overlookmotel/toposort-extended)
[![Dev dependency Status](https://img.shields.io/david/dev/overlookmotel/toposort-extended.svg)](https://david-dm.org/overlookmotel/toposort-extended)
[![Coverage Status](https://img.shields.io/coveralls/overlookmotel/toposort-extended/master.svg)](https://coveralls.io/r/overlookmotel/toposort-extended)

API is stable and tests cover all options. No known issues.

## Usage

### Main method
#### toposort(edges)

```js
var toposort = require('toposort-extended');

sorted = toposort( [
	[ { table: 'Ingredient' }, { table: 'Shop' } ],
	[ { table: 'Food' }, { table: 'Ingredient' } ]
] );

// sorted = [ { table: 'Food' }, { table: 'Ingredient' }, { table: 'Shop' } ]
```

Exactly the same as original [toposort](https://github.com/marcelklehr/toposort), except:

* Inputs are converted to JSON before ordering so objects can be used as input
* Cyclic dependency errors are thrown as custom class `toposort.Error` with the source of the error passed as `edge`

#### toposort.dependents(edges)

Same as `toposort(edges)` except that items which are not dependent on any other item are excluded from the returned array.

```js
sorted = toposort.dependents( [
	[ { table: 'Ingredient' }, { table: 'Shop' } ],
	[ { table: 'Food' }, { table: 'Ingredient' } ]
] );

// sorted = [ { table: 'Food' }, { table: 'Ingredient' } ]
```

## Changelog

See changelog.md

## Tests

Use `npm test` to run the tests. Use `npm run cover` to check coverage.

## Issues

If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/toposort-extended/issues

## Contribution

Pull requests are very welcome. Please:

* ensure all tests pass before submitting PR
* add an entry to changelog
* add tests for new features
* document new functionality/API additions in README

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