<commit_before># 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

API is stable and no known issues.

## Usage

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

	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.

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

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

## Changelog

See changelog.md

## Tests

None! It's so simple, it doesn't really need them.

## Issues

If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/toposort-extended/issues<commit_msg>README update<commit_after># 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

[![Build Status](https://secure.travis-ci.org/overlookmotel/toposort-extended.png)](http://travis-ci.org/overlookmotel/toposort-extended)
[![Dependency Status](https://david-dm.org/overlookmotel/toposort-extended.png)](https://david-dm.org/overlookmotel/toposort-extended)

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

## Usage

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

	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.

	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.

## Issues

If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/toposort-extended/issues
{'fraction_non_alphanumeric': 0.14427701186277653, 'fraction_numerical': 0.0, 'mean_word_length': 4.089722675367048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '692436', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1046, 'n_words': 310}