Skip to content
Snippets Groups Projects
Verified Commit 516da111 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: commit save point

parent 14152bb2
No related branches found
No related tags found
No related merge requests found
Showing
with 168 additions and 0 deletions
import {BaseWithOptions} from '@schukai/monster/source/types/basewithoptions.mjs';
class My extends BaseWithOptions {
get defaults() {
return Object.assign({}, super.defaults, {
mykey: true
});
}
}
import {isIterable} from '@schukai/monster/source/types/is.mjs';
isIterable(null) // ↦ false
isIterable('hello') // ↦ true
isIterable([]) // ↦ true
\ No newline at end of file
import {isInteger} from '@schukai/monster/source/types/is.mjs';
isInteger(() => {
}) // ↦ true
isInteger('2') // ↦ false
isInteger(2) // ↦ true
import {isPrimitive} from '@schukai/monster/source/types/is.mjs';
isPrimitive('2') // ↦ true
isPrimitive([]) // ↦ false
\ No newline at end of file
import {isSymbol} from '@schukai/monster/source/types/is.mjs';
isSymbol(Symbol('a')) // ↦ true
isSymbol([]) // ↦ false
\ No newline at end of file
import {isBoolean} from '@schukai/monster/source/types/is.mjs';
isBoolean('2') // ↦ false
isBoolean([]) // ↦ false
isBoolean(2 > 4) // ↦ true
\ No newline at end of file
import {isString} from '@schukai/monster/source/types/is.mjs';
isString('2') // ↦ true
isString([]) // ↦ false
\ No newline at end of file
import {isObject} from '@schukai/monster/source/types/is.mjs';
isObject('2') // ↦ false
isObject([]) // ↦ false
\ No newline at end of file
import {isInstance} from '@schukai/monster/source/types/is.mjs';
isInstance('2') // ↦ false
isInstance([]) // ↦ false
\ No newline at end of file
import {isArray} from '@schukai/monster/source/types/is.mjs';
isArray('2') // ↦ false
isArray([]) // ↦ true
\ No newline at end of file
import {isFunction} from '@schukai/monster/source/types/is.mjs';
isFunction(() => {
}) // ↦ true
isFunction('2') // ↦ false
isFunction([]) // ↦ false
\ No newline at end of file
import {Node} from '@schukai/monster/source/types/node.mjs';
import {NodeRecursiveIterator} from '@schukai/monster/source/types/noderecursiveiterator.mjs';
const node = new Node('1')
// 1
// 2
// ├ 2.1
// ├ 2.2
// └ 2.3
// 3
// 4
// ├ 4.1
// └ 4.2
node.appendChild(
(new Node('2'))
.appendChild(new Node('2.1'))
.appendChild(new Node('2.2'))
.appendChild(new Node('2.3')))
.appendChild(new Node('3'))
.appendChild(new Node('4')
.appendChild(new Node('4.1'))
.appendChild(new Node('4.2')));
const iterator = new NodeRecursiveIterator(node);
const result = [];
for (const n of iterator) {
result.push(n.value);
}
// ↦ ['1', '2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2']
import {Observer} from '@schukai/monster/source/types/observer.mjs';
const observer = new Observer(function (a, b, c) {
console.log(this, a, b, c); // ↦ "a", 2, true
}, "a", 2, true);
observer.update({value: true}).then(() => {
});
// ↦ {value: true} "a" 2 true
\ No newline at end of file
import {ProxyObserver} from '@schukai/monster/source/types/proxyobserver.mjs';
import {Observer} from '@schukai/monster/source/types/observer.mjs';
import {isObject} from '@schukai/monster/source/types/is.mjs';
const o = new Observer(function () {
if (isObject(this) && this instanceof ProxyObserver) {
// do something (this ist ProxyObserver)
const subject = this.getSubject();
console.log(subject);
}
});
let realSubject = {
a: {
b: {
c: true
},
d: 9
}
}
const p = new ProxyObserver(realSubject);
p.attachObserver(o);
const s = p.getSubject();
s.a.b.c = false;
import {Queue} from '@schukai/monster/source/types/queue.mjs';
const queue = new Queue;
queue.add(2);
queue.add(true);
queue.add("Hello");
queue.add(4.5);
console.log(queue.poll());
// ↦ 2
console.log(queue.poll());
// ↦ true
console.log(queue.poll());
// ↦ "Hello"
console.log(queue.poll());
// ↦ 4.5
console.log(queue.poll());
// ↦ undefined
import {TokenList} from '@schukai/monster/source/types/tokenlist.mjs';
typeof new TokenList("myclass row")[Symbol.iterator];
// ↦ "function"
\ No newline at end of file
import {TokenList} from '@schukai/monster/source/types/tokenlist.mjs';
new TokenList("start middle end").contains('start'); // ↦ true
new TokenList("start middle end").contains('end'); // ↦ true
new TokenList("start middle end").contains('xyz'); // ↦ false
new TokenList("start middle end").contains(['end','start','middle']); // ↦ true
new TokenList("start middle end").contains(['end','start','xyz']); // ↦ false
\ No newline at end of file
import {TokenList} from '@schukai/monster/source/types/tokenlist.mjs';
new TokenList().add("abc xyz").toString(); // ↦ "abc xyz"
new TokenList().add(["abc", "xyz"]).toString(); // ↦ "abc xyz"
new TokenList().add(undefined); // ↦ add nothing
\ No newline at end of file
import {TokenList} from '@schukai/monster/source/types/tokenlist.mjs';
new TokenList("abc xyz").remove("xyz").toString(); // ↦ "abc"
new TokenList("abc xyz").remove(["xyz"]).toString(); // ↦ "abc"
new TokenList("abc xyz").remove(undefined); // ↦ remove nothing
\ No newline at end of file
import {TokenList} from '@schukai/monster/source/types/tokenlist.mjs';
new TokenList("abc def ghi").toggle("def xyz").toString(); // ↦ "abc ghi xyz"
new TokenList("abc def ghi").toggle(["abc", "xyz"]).toString(); // ↦ "def ghi xyz"
new TokenList().toggle(undefined); // ↦ nothing
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment