Warning: mkdir(): No space left on device in /var/www/tgoop/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/HowProgrammingWorks/--): Failed to open stream: No such file or directory in /var/www/tgoop/post.php on line 50
HowProgrammingWorks - JavaScript and Node.js Programming@HowProgrammingWorks P.1822
HOWPROGRAMMINGWORKS Telegram 1822
πŸ‘©β€πŸ’» Π­Ρ‚ΠΎ Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅Π²ΠΌΠ΅ΡΡ‚ΠΎ нСпринятого TC39 ΠΈΠΌΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½ΠΎΠ³ΠΎ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π°
- ΠΈΠΌΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ‹Π΅ ΠΌ ΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ‹Π΅ записи (ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Ρ‹) с ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·Π°Ρ†ΠΈΠ΅ΠΉ Ρ„ΠΎΡ€ΠΌΡ‹
- ΠΏΠΎΠ»Π½ΠΎΠ΅ ΠΊΠ»ΠΎΠ½ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅, модификация, ΠΊΠ»ΠΎΠ½ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ с ΠΏΡ€ΠΎΡ‚ΠΎΡ‚ΠΈΠΏΠ½Ρ‹ΠΌ наслСдованиСм
- ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° Ρ‚ΠΈΠΏΠΎΠ² Π² Ρ€Π°Π½Ρ‚Π°ΠΉΠΌΠ΅, Π΄Π΅Ρ„ΠΎΠ»Ρ‚Π½Ρ‹Π΅ значСния ΠΏΠΎΠ»Π΅ΠΉ
- ΠΈΠΌΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ‹Π΅ записи с экономиСй памяти Π·Π° счСт Ρ†Π΅ΠΏΠΎΡ‡Π΅ΠΊ ΠΏΡ€ΠΎΡ‚ΠΎΡ‚ΠΈΠΏΠΎΠ²
- ускорСниС поиска ΠΏΠΎΠ»Π΅ΠΉ ΠΈ ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·Π°Ρ†ΠΈΠΈ для V8, Π΄Π°ΠΆΠ΅ Π² сравнСнии с Π»ΠΈΡ‚Π΅Ρ€Π°Π»ΠΎΠΌ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π°
Π’ΡƒΡ‚ Π΅Ρ‰Π΅ Π½ΡƒΠΆΠ½ΠΎ ΠΌΠ½ΠΎΠ³ΠΎΠ΅ ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ, Π½ΠΎ ΠΏΠΎΠ»Π½ΠΎΠ΅ Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅ Π±ΡƒΠ΄Π΅Ρ‚ Ρ‚ΡƒΡ‚: https://github.com/metarhia/metautil/pull/298
class Record {
static immutable(defaults) {
return Record.#build(defaults, false);
}

static mutable(defaults) {
return Record.#build(defaults, true);
}

static #build(defaults, isMutable) {
const fields = Object.keys(defaults);
const defaultValues = Object.create(null);
for (const key of fields) {
defaultValues[key] = defaults[key];
}

class Struct {
static fields = fields;
static defaults = defaultValues;
static mutable = isMutable;

static create(data = {}) {
const obj = Object.create(null);
for (const key of fields) {
const base = defaultValues[key];
const value = key in data ? data[key] : base;
if (!Record.#sameType(base, value)) {
const exp = Record.#typeof(base);
const act = Record.#typeof(value);
throw new TypeError(
`Invalid type for "${key}": expected ${exp}, got ${act}`,
);
}
obj[key] = value;
}
return isMutable ? Object.seal(obj) : Object.freeze(obj);
}
}
return Struct;
}

static #typeof(value) {
if (Array.isArray(value)) return 'array';
if (value === null) return 'null';
return typeof value;
}

static #sameType(a, b) {
if (Array.isArray(a)) return Array.isArray(b);
if (a === null) return b === null;
return typeof a === typeof b;
}

static #validate(instance, updates) {
for (const key of Object.keys(updates)) {
if (!Reflect.has(instance, key)) continue;
const current = instance[key];
const next = updates[key];
if (!Record.#sameType(current, next)) {
const exp = Record.#typeof(current);
const act = Record.#typeof(next);
throw new TypeError(
`Invalid type for "${key}": expected ${exp}, got ${act}`,
);
}
}
}

static update(instance, updates) {
if (Object.isFrozen(instance)) {
throw new Error('Cannot mutate immutable Record');
}
Record.#validate(instance, updates);
for (const key of Object.keys(updates)) {
if (Reflect.has(instance, key)) {
instance[key] = updates[key];
}
}
return instance;
}

static fork(instance, updates) {
Record.#validate(instance, updates);
const obj = Object.create(null);
for (const key of Object.keys(instance)) {
obj[key] = Reflect.has(updates, key) ? updates[key] : instance[key];
}
return Object.isFrozen(instance) ? Object.freeze(obj) : Object.seal(obj);
}

static branch(instance, updates) {
Record.#validate(instance, updates);
const obj = Object.create(instance);
for (const key of Object.keys(updates)) {
Reflect.defineProperty(obj, key, {
value: updates[key],
writable: true,
configurable: true,
enumerable: true,
});
}
return Object.isFrozen(instance) ? Object.freeze(obj) : Object.seal(obj);
}
}
Please open Telegram to view this post
VIEW IN TELEGRAM
❀6πŸ‘3πŸ”₯1



tgoop.com/HowProgrammingWorks/1822
Create:
Last Update:

πŸ‘©β€πŸ’» Π­Ρ‚ΠΎ Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅Π²ΠΌΠ΅ΡΡ‚ΠΎ нСпринятого TC39 ΠΈΠΌΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½ΠΎΠ³ΠΎ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π°
- ΠΈΠΌΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ‹Π΅ ΠΌ ΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ‹Π΅ записи (ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Ρ‹) с ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·Π°Ρ†ΠΈΠ΅ΠΉ Ρ„ΠΎΡ€ΠΌΡ‹
- ΠΏΠΎΠ»Π½ΠΎΠ΅ ΠΊΠ»ΠΎΠ½ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅, модификация, ΠΊΠ»ΠΎΠ½ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ с ΠΏΡ€ΠΎΡ‚ΠΎΡ‚ΠΈΠΏΠ½Ρ‹ΠΌ наслСдованиСм
- ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° Ρ‚ΠΈΠΏΠΎΠ² Π² Ρ€Π°Π½Ρ‚Π°ΠΉΠΌΠ΅, Π΄Π΅Ρ„ΠΎΠ»Ρ‚Π½Ρ‹Π΅ значСния ΠΏΠΎΠ»Π΅ΠΉ
- ΠΈΠΌΠΌΡƒΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ‹Π΅ записи с экономиСй памяти Π·Π° счСт Ρ†Π΅ΠΏΠΎΡ‡Π΅ΠΊ ΠΏΡ€ΠΎΡ‚ΠΎΡ‚ΠΈΠΏΠΎΠ²
- ускорСниС поиска ΠΏΠΎΠ»Π΅ΠΉ ΠΈ ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·Π°Ρ†ΠΈΠΈ для V8, Π΄Π°ΠΆΠ΅ Π² сравнСнии с Π»ΠΈΡ‚Π΅Ρ€Π°Π»ΠΎΠΌ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π°
Π’ΡƒΡ‚ Π΅Ρ‰Π΅ Π½ΡƒΠΆΠ½ΠΎ ΠΌΠ½ΠΎΠ³ΠΎΠ΅ ΠΎΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ, Π½ΠΎ ΠΏΠΎΠ»Π½ΠΎΠ΅ Ρ€Π΅ΡˆΠ΅Π½ΠΈΠ΅ Π±ΡƒΠ΄Π΅Ρ‚ Ρ‚ΡƒΡ‚: https://github.com/metarhia/metautil/pull/298

class Record {
static immutable(defaults) {
return Record.#build(defaults, false);
}

static mutable(defaults) {
return Record.#build(defaults, true);
}

static #build(defaults, isMutable) {
const fields = Object.keys(defaults);
const defaultValues = Object.create(null);
for (const key of fields) {
defaultValues[key] = defaults[key];
}

class Struct {
static fields = fields;
static defaults = defaultValues;
static mutable = isMutable;

static create(data = {}) {
const obj = Object.create(null);
for (const key of fields) {
const base = defaultValues[key];
const value = key in data ? data[key] : base;
if (!Record.#sameType(base, value)) {
const exp = Record.#typeof(base);
const act = Record.#typeof(value);
throw new TypeError(
`Invalid type for "${key}": expected ${exp}, got ${act}`,
);
}
obj[key] = value;
}
return isMutable ? Object.seal(obj) : Object.freeze(obj);
}
}
return Struct;
}

static #typeof(value) {
if (Array.isArray(value)) return 'array';
if (value === null) return 'null';
return typeof value;
}

static #sameType(a, b) {
if (Array.isArray(a)) return Array.isArray(b);
if (a === null) return b === null;
return typeof a === typeof b;
}

static #validate(instance, updates) {
for (const key of Object.keys(updates)) {
if (!Reflect.has(instance, key)) continue;
const current = instance[key];
const next = updates[key];
if (!Record.#sameType(current, next)) {
const exp = Record.#typeof(current);
const act = Record.#typeof(next);
throw new TypeError(
`Invalid type for "${key}": expected ${exp}, got ${act}`,
);
}
}
}

static update(instance, updates) {
if (Object.isFrozen(instance)) {
throw new Error('Cannot mutate immutable Record');
}
Record.#validate(instance, updates);
for (const key of Object.keys(updates)) {
if (Reflect.has(instance, key)) {
instance[key] = updates[key];
}
}
return instance;
}

static fork(instance, updates) {
Record.#validate(instance, updates);
const obj = Object.create(null);
for (const key of Object.keys(instance)) {
obj[key] = Reflect.has(updates, key) ? updates[key] : instance[key];
}
return Object.isFrozen(instance) ? Object.freeze(obj) : Object.seal(obj);
}

static branch(instance, updates) {
Record.#validate(instance, updates);
const obj = Object.create(instance);
for (const key of Object.keys(updates)) {
Reflect.defineProperty(obj, key, {
value: updates[key],
writable: true,
configurable: true,
enumerable: true,
});
}
return Object.isFrozen(instance) ? Object.freeze(obj) : Object.seal(obj);
}
}

BY HowProgrammingWorks - JavaScript and Node.js Programming


Share with your friend now:
tgoop.com/HowProgrammingWorks/1822

View MORE
Open in Telegram


Telegram News

Date: |

Developing social channels based on exchanging a single message isn’t exactly new, of course. Back in 2014, the β€œYo” app was launched with the sole purpose of enabling users to send each other the greeting β€œYo.” It’s easy to create a Telegram channel via desktop app or mobile app (for Android and iOS): Telegram desktop app: In the upper left corner, click the Menu icon (the one with three lines). Select β€œNew Channel” from the drop-down menu. Read now Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020.
from us


Telegram HowProgrammingWorks - JavaScript and Node.js Programming
FROM American