We will soon be 10000 members!

General Discussion

Suggested Topics


  • 0 Votes
    1 Posts
    341 Views

    Looking for swedish speaking members. I hope that we are more than 15 šŸ˜‰ @Swedish-Members

    15 000+ members and only 15 that can write in swedish ;( Maybe when we are 16 000+ we get 16 members šŸ˜› Nice ratio indeed!

  • 0 Votes
    1 Posts
    992 Views

    I propose to either add a new ability for
    the const keyword or use the reserved word final to make
    non-writable object and class members.

    Note: The TypeErrors are thrown following the behavior of Object.freeze or
    a { configurable: false, writable: false } property descriptor. They
    will be thrown in a "use strict"; environment, but usually not
    otherwise.

    Constant Class or Object members / properties / fields / methods

    Use final, since it is an unused reserved word, or possibly const to define constant Class or Object members:

    class X { // const / final now makes static class properties // non-writable, and non-configurable static const abc = 123; static final abc = 123; // also works to make constant private properties const #def = 456; final #def = 456; // as well as constant normal class fields, if you're into that const ghi = 789; final ghi = 789; // and constant private / static / normal methods static const doSomething() { } static final doSomething() { } const #somethingPrivate() { } final #somethingPrivate() { } const cantChangeMe() { } final cantChangeMe() { } constructor(a = 3) { const somethingPrivate = this.#somethingPrivate; // throws new TypeError('Assignment to constant property.') this.#somethingPrivate = function () { return a; } this.#somethingPrivate === somethingPrivate // true const def = this.#def; // throws new TypeError('Assignment to constant property.') this.#def = 1000; this.#def === def // true } } const x = new X(); const ghi = x.ghi; // throws new TypeError('Assignment to constant property.') x.ghi = 2000; x.ghi === ghi // true const doSomething = X.doSomething; // throws new TypeError('Assignment to constant property.') X.doSomething = function doSomethingElse() { }; X.doSomething === doSomething // true const cantChangeMe = X.prototype.cantChangeMe; // throws new TypeError('Assignment to constant property.') X.prototype.cantChangeMe = function yesICan() { }; X.prototype.cantChangeMe === cantChangeMe // true const o = { // const / final can be used in normal object literals, too const things() { }, final things() { }, const prop: 5, final prop: 5, }; const things = o.things; // throws new TypeError('Assignment to constant property.') o.things = function stuff() { }; o.things === things // true const prop = o.prop; // throws new TypeError('Assignment to constant property.') o.prop = 11; o.prop === prop // true

    This could be transpiled by simply using Object.defineProperty like so,
    at least on public members:

    class X { static abc = 123; static doSomething() { } cantChangeMe() { } constructor() { } } ['abc', 'doSomething', 'cantChangeMe'].forEach(key => Object.defineProperty(X, key, { configurable: false, writable: false }) ); const o = { things() { }, prop: 5, }; ['things', 'prop'].forEach(key => Object.defineProperty(o, key, { configurable: false, writable: false }) ); Shorthand for Immutable Classes and Objects

    Defining everything as final or const in a Class or Object doesn't quiet
    do the job. What if we want true immutability?

    I've also looked into some kind of special syntax for creating immutable
    objects and making classes return immutable objects. Maybe we could use
    final for that, as well?

    // The static members and prototype of this class are shallow immutable. // Any object it returns is also shallow immutable, // similar to `return Object.freeze(this)` as the last line in the constructor, // though since it uses a keyword, it could throw an error on an attempt to override final class ConstantObject { static abc = 123; static doSomething() { } cantChangeMe() { } constructor() { this.d = 8; } } const constantObject = new ConstantObject(); const c = constantObject.c; // throws new TypeError('Assignment to constant property.') constantObject.c = 321; constantObject.c = c // true const doSomething = ConstantObject.doSomething; // throws new TypeError('Assignment to constant property.') ConstantObject.doSomething = function doSomethingElse() { }; ConstantObject.doSomething === doSomething // true const cantChangeMe = ConstantObject.prototype.cantChangeMe; // throws new TypeError('Assignment to constant property.') ConstantObject.prototype.cantChangeMe = function yesICan() { }; ConstantObject.prototype.cantChangeMe === cantChangeMe // true // No members can be added / modified / deleted from this shallow immutable object. const finalObject = final { prop: 5, things() { }, }; const things = finalObject.things; // throws new TypeError('Assignment to constant property.') finalObject.things = function stuff() { }; finalObject.things === things // true const prop = finalObject.prop; // throws new TypeError('Assignment to constant property.') finalObject.prop = 11; finalObject.prop === prop // true

    This could be transpiled essentially by just using Object.freeze and Object.defineProperty:

    const ConstantObject = (() => { class ConstantObject { static abc = 123; static doSomething() { } cantChangeMe() { } constructor() { this.d = 8; return Object.freeze(this); } } Object.defineProperty(ConstantObject, 'prototype', { value: Object.freeze(ConstantObject.prototype), }); return Object.freeze(ConstantObject); })(); const finalObject = Object.freeze({ prop: 5, things() { }, });

    What do you think? I'm currently leaning towards using the final keyword for everything.
    Both sides have pros and cons.

    const final Pros • Meaningful word • Unused • Fits existing syntax; AKA const x = 5 -> const x: 5 • Meaning could be closer if devs want to initialize after definition • Familiar to Java devs Cons • Could be overloaded in usage • Less meaningful to C / JS devs, could be confusing
  • 0 Votes
    3 Posts
    894 Views

    My thoughts about thoughts @yariplus :

    Not sure what this means. Like the amount of links? or total uploaded files?

    Yes, total uploaded files in post. For example, one can attach only five images in the message.

    Oh, maybe you mean editing the post in HTML mode like some forums have, that might be neat.

    Maybe that's what I mean. For example, can lead editor xenforo -

    12.png

    fyi, This information is already on the profile page of each user.
    It might be nice to have a User Statistics page with a table displaying this type of information.

    I delete it there. Quite a strange place to display ip addresses. I think that it would be wiser to display them in the admin control panel (ADMIN CONTROL PANEL - MANAGE - USERS).

    What about - 'Guests posts in topics do not appear immediately. Guests need to refresh the page. It seems to me that this is not good'?

    Guests must refresh the page topic, to see new messages.
    Those who logged - new messages appear immediately. No need to refresh the page to see the new messages in the thread.
    It would be better if guests also would not have to refresh the page.
    Check it out.

  • 0 Votes
    7 Posts
    3k Views

    @yariplus It's cool! Thanks!

  • 0 Votes
    2 Posts
    2k Views

    Hello @mrneilypops!

    NodeBB plans range from $35 to $100, depending on the feature set.

    $75 and up plans give you advantages like custom DNS forwarding (so you can use something like mypersonaldomain.com instead of myapp.nodebb.com) and daily backups. All plans come with use of the support ticket system, so you can reach us for support for individual instances.

    If you have any other questions, please give us a shout at [email protected] šŸ™‚