Skip to content

Instantly share code, notes, and snippets.

(function (Function, Array) {
var
function_prototype = Function.prototype,
isFunction = (function (TYPEOF_FUNCTION) {
return function (type) {
return ((typeof type == TYPEOF_FUNCTION)
&& (typeof type.call == TYPEOF_FUNCTION)
@petsel
petsel / Object.compare.js
Created September 19, 2016 14:31
A generic approach of a possible static `Object.compare` implementation.
(function (Object) {
var
expose_internal_value = Object.prototype.valueOf,
NULL_VALUE = null,
composable("composites.Range", function (require, global) {
"use strict";
require("environment_extended_introspective_core");
@petsel
petsel / Array.flatten.js
Last active October 10, 2016 09:45
"Math.average", "Math.sum", "Array.flatten", "Array.shuffle", "Enumerable.shuffle", "Array.unique", "Enumerable.unique"
composable("composites.Array_flatten", function (require, global) {
"use strict";
var
environment = require("environment_extended_introspective_core"),
environment_introspective = environment.introspective,
@petsel
petsel / Function.toApplicator.js
Last active December 23, 2016 10:00
Prevent function based "Role" pattern implementations[1] like "Mixin"s, "Trait"s or "Talent"s from getting instantiated by turning them into callable objects. Thus creating real objects but providing [call] and [apply] as standard call/delegation methods to them.
/**
*
* Prevent function based "Role" pattern implementations[1] like "Mixin"s,
* "Trait"s or "Talent"s from getting instantiated by turning them into
* callable objects. Thus creating real objects but providing [call] and
* [apply] as standard call/delegation methods to them.
*
* The concept will be promoted as "Applicator" in order to distinguish
* it from "Constructor". (Though in theirs wording both do follow the
* same track.)
@petsel
petsel / esx-trait_example-code_proposal.js.scala
Created February 14, 2017 12:46
example pseudo code featuring a possible next generation ECMAScript Trait Syntax
trait customTrait {
use { Trait_A, Trait_B, Trait_C }
apply all
apply all without { methodName_z, methodName_y }
apply { Trait_A }
@petsel
petsel / The-many-Talents-of-JavaScript.md
Last active February 21, 2017 11:33
The-many-Talents-of-JavaScript.md

#The many »Talents« of JavaScript

[TOC]

##The many talents of JavaScript for generalizing Role Oriented Programming approaches like Traits and Mixins

###TL;DR / Summary

(function (global) {
'use strict';
var
Array = global.Array,
Object = global.Object,
RegExp = global.RegExp,
Function = global.Function,
// file "Object.getMaxDepth.js"
const Object = global.Object;
const object_prototype_toString = Object.prototype.toString;
const object_keys = Object.keys;
const math_max = global.Math.max;
const isArray = global.Array.isArray;
// example-of-function-based-mixin-composition-with-class-and-shared-local-state.js
function withExposableSharedLocalState (state) {
state = ((typeof state === "object") && state) || (void 0);
var json_stringify = JSON.stringify;
var json_parse = JSON.parse;
var compositeType = this;