Skip to content

Instantly share code, notes, and snippets.

View Boolean.isTrue.isFalse.js
/**
* `Boolean.isTrue` / `Boolean.isFalse` is a fun implementation of Smalltalk's [https://en.wikipedia.org/wiki/Smalltalk]
* `ifTrue` / `ifFalse` control structures [https://en.wikipedia.org/wiki/Smalltalk#Control_structures].
*
* It is nothing one would really desire in JavaScript unless one is looking for an alternative to its native `if...else`
* statement and has deeply fallen in love with using function expressions all along.
*
* EN: [https://en.wikipedia.org/wiki/Smalltalk#Control_structures]
* DE: [https://de.wikipedia.org/wiki/Smalltalk_(Programmiersprache)#IF-Anweisung]
*/
View Function.compose.js
// see: "Compose in JavaScript, not applying functions correctly?" asked by Dan Mantyla - Nov 10, 2014
// answer: [https://stackoverflow.com/questions/26835095/compose-in-javascript-not-applying-functions-correctly/28880612#28880612]
(function (Function, Object) {
const fctPrototype = Function.prototype;
const FUNCTION_TYPE = (typeof Function);
function isFunction(type) {
return (
@petsel
petsel / Function.afterThrowing.js
Created Sep 2, 2020
implementation of a possible static `Function.afterThrowingAll` which does run a list of whatever functions failsafe
View Function.afterThrowing.js
// see [https://gist.github.com/petsel/9ddf5ce515f1344c84bd#file-function-afterthrowing-js]
(function (Function) {
const fctPrototype = Function.prototype;
const FUNCTION_TYPE = (typeof Function);
function isFunction(type) {
return (
(typeof type == FUNCTION_TYPE)
@petsel
petsel / Function.afterFinally.js
Created Sep 2, 2020
implementation of a possible static `Function.afterFinallyAll` which does run a list of whatever functions failsafe
View Function.afterFinally.js
// see [https://gist.github.com/petsel/3b31cd5e63d43b9e7c4e#file-function-afterfinally-js]
(function (Function) {
const fctPrototype = Function.prototype;
const FUNCTION_TYPE = (typeof Function);
function isFunction(type) {
return (
(typeof type == FUNCTION_TYPE)
View getAllAccessiblePropertyNames.js
function isBooleanValue(type) {
return (typeof type === 'boolean');
}
function isNumberValue(type) {
return (typeof type === 'number');
}
function isStringValue(type) {
return (typeof type === 'string');
}
View example-of-function-based-mixin-composition-with-class-and-shared-local-state.js
// 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;
View Object.getMaxDepth.js
// 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;
View Function.memoize.js
(function (global) {
'use strict';
var
Array = global.Array,
Object = global.Object,
RegExp = global.RegExp,
Function = global.Function,
View Function.clocked.js
(function (global, Math, Function) {
'use strict';
var
DEFAULT_INTERVALL = 200,
TYPEOF_FUNCTION_TYPE = 'function', // assigning the result of (typeof Function) will save two byte if minified.
isFunction = function (type) {
@petsel
petsel / Array.removeFirstMatch.removeLastMatch.removeEveryMatch.js
Created Nov 10, 2017
implementation of 3 filter-method based, prototypal `Array` methods - `Array#removeFirstMatch`, `Array#removeLastMatch`, `Array#removeEveryMatch`.
View Array.removeFirstMatch.removeLastMatch.removeEveryMatch.js
/**
* [Array.removeFirstMatch.removeLastMatch.removeEveryMatch.js]
*
* implementation of 3 filter-method based, prototypal `Array` methods - `Array#removeFirstMatch`, `Array#removeLastMatch`, `Array#removeEveryMatch`.
*/
(function (ReferenceError, TypeError, Object, Array) {
"use strict";
var
You can’t perform that action at this time.