Context Oriented Programming (COP) for ECMAScript 6

Usage no npm install needed!

<script type="module">
  import contextjs from '';



Context-oriented Programming (COP) for JavaScript

Example Code

import { layer, proceed, withLayers } from ""

class Foo {
    bar() {
        return 3

const L1 = layer("L1")
L1.refineClass(Foo, {
    bar() { return proceed() + 4}

let o = new Foo()  // 3
withLayers([L1], () =>  // 7

Further Functionality

Further functionality can be added via

import { withoutLayers, Layer } from ""
import * as cop from ""

Global import of ContextJS

If you would like to add the functions and classes exported from the contetxjs Module (proceed, withLayers etc.) into the window or global object, so you do not have to enumerate the identifiers in the import statement and do not need to prefix them with a "namespace", you can write import "".