Skip to content

Instantly share code, notes, and snippets.

@petsel
petsel / Array.removeFirstMatch.removeLastMatch.removeEveryMatch.js
Last active February 22, 2021 17:24
Implementation of 3 condition-function based, prototypal `Array` methods which do mutate each their processed array reference.
/**
*
* [Array.removeFirstMatch.removeLastMatch.removeEveryMatch.js]
*
* Implementation of 3 condition-function based, prototypal `Array` methods
* which do mutate each their processed array reference.
*
* - `Array.prototype.removeFirstMatch`,
* - `Array.prototype.removeLastMatch`,
* - `Array.prototype.removeEveryMatch`
@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 / esx-trait.js
Last active August 25, 2023 08:23
Just Another "Trait Composition Language" Library for ECMAScript
//
//
// Just Another "Trait Composition Language" Library for ECMAScript
//
//
(function (global) { // module (pattern).
@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,
(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)
composable("composites.Range", function (require, global) {
"use strict";
require("environment_extended_introspective_core");
@petsel
petsel / Object.with.without.js
Created October 5, 2015 13:30
prototypal object (de)composition methods targeting function based Traits/Mixins working from an [Object] based view as antipode to [Function.call/apply].
(function (Object, Array) {
"use strict";
var
object_prototype = Object.prototype,
isObject = function is_object (type) {
@petsel
petsel / Array.reject.js
Last active February 22, 2021 17:25
Implementation of a condition-function based, prototypal `Array` method which returns rejected array items and does mutate its processed array.
/**
*
* [Array.reject.js]
*
* Implementation of a condition-function based, prototypal `Array` method
* which returns rejected array items and does mutate its processed array.
*
* - `Array.prototype.reject`
*
*/
@petsel
petsel / custom-module-system-core.js
Created May 19, 2015 19:09
module system core ... able of being custom named/branded but also with "white label" fall-back.
(function (global, moduleSystemName, namespace) {
"use strict";
var
moduleSystem, // the "custom named" module system core.
@petsel
petsel / Array.interlock.js
Last active February 23, 2021 19:22
Implementation of a prototypal `Array` method which, from both processed iterable structures, interlocks each item of same index, pairwise and repeatedly into a new array. Sparse locations on either side will be recognized and accordingly (re)assigned.
/**
*
* [Array.interlock.js]
*
* Implementation of a prototypal `Array` method which,
* from both processed iterable structures, interlocks
* each item of same index, pairwise and repeatedly
* into a new array.
* Sparse locations on either side will be recognized
* and accordingly (re)assigned.