testing "classes"

Benchmark created on


Description

each are different types of "classes" made in JavaScript, some traditional, others are extremely abstract

Test runner

Ready to run.

Testing in
TestOps/sec
Curry 'Class'
let 
    classy = (name, age, height) => prop=> (
        prop == 'name' ? update=> (name = update ?? name) :
        prop == 'age' ? update=> (age = update ?? age) :
        prop == 'height' ? update=> (height = update ?? height) :
        prop == 'obj' ? cb => cb(name,age,height) :
        ()=>'oops'
    ),
    steve = classy('Steve', 34, 189);

console.log(
    steve("obj")((...i)=>i),
    steve("name")('Henry'),
    steve("age")(44),
    steve("height")(160),
    steve("obj")((...i)=>i)
);
ready
Class with Obj condition
let 
    classy = (name, age, height) => prop=> ({
    	obj:cb=>cb(name,age,height),
    	name:update=>(name = update ?? name),
    	age:update=>(age = update ?? age),
    	height:update=>(height= update ?? height)
    })?.[prop],
    steve = classy('Steve', 34, 189);

console.log(
    steve("obj")((...i)=>i),
    steve("name")('Henry'),
    steve("age")(44),
    steve("height")(160),
    steve("obj")((...i)=>i)
);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.