Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/federicobond/c3-linearization
A package for doing Solidity and Python-style C3-linearization in ECMAScript
https://github.com/federicobond/c3-linearization
algorithm c3 linearization mro nodejs python solidity
Last synced: 3 months ago
JSON representation
A package for doing Solidity and Python-style C3-linearization in ECMAScript
- Host: GitHub
- URL: https://github.com/federicobond/c3-linearization
- Owner: federicobond
- License: mit
- Created: 2018-03-23T02:50:42.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T10:58:59.000Z (over 6 years ago)
- Last Synced: 2024-08-11T11:26:21.772Z (5 months ago)
- Topics: algorithm, c3, linearization, mro, nodejs, python, solidity
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 14
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
c3-linearization
================[![Build Status](https://travis-ci.org/federicobond/c3-linearization.svg?branch=master)](https://travis-ci.org/federicobond/c3-linearization)
![npm version](https://img.shields.io/npm/v/c3-linearization.svg)A package for doing Python-style C3-linearization in ECMAScript.
## Usage
```javascript
import { linearize } from 'c3-linearization'linearize({
'A': ['B', 'C'],
'B': [],
'C': ['D'],
'D': []
})// {
// 'A': ['A', 'B', 'C', 'D'],
// 'B': ['B'],
// 'C': ['C', 'D'],
// 'D': ['D']
// }
```### Important notes
*Solidity* does linearization from right to left (you write the parents from most
base-like to most derived). This is exactly the reverse as in Python, where you
put the most derived classes to the left. To get correct results with Solidity,
set the `reverse` option to true.```javascript
linearize('A': ['B', 'C'], { reverse: true })
```*Python* is also a bit more strict in the cases that it accepts. For accurate
Python MRO, set the `python` option to true.```javascript
linearize('A': ['B', 'C'], { python: true })
```## Author
Federico Bond
## License
MIT