Socket
Socket
Sign inDemoInstall

c3-linearization

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

c3-linearization

A package that implements the C3 linearization algorithm


Version published
Weekly downloads
795
decreased by-19.62%
Maintainers
1
Weekly downloads
 
Created
Source

c3-linearization

Build Status npm version

A package for doing Python-style C3-linearization in ECMAScript.

Usage

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.

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.

linearize('A': ['B', 'C'], { python: true })

Author

Federico Bond

License

MIT

Keywords

FAQs

Package last updated on 01 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc