![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Automatic/Convenience/Syntactic-Sugar Symbol.for() access: `const {WHATEVER,Vars,youWant} = require("syms")`
This library is a "magic" proxy object, which generates Symbol.for()
type symbols on property access after performing a few key normalization steps, resulting in the following:
syms.foo
becomes Symbol.for("foo")
syms.TWO_WORDS
becomes Symbol.for("two.words")
syms._two_words
becomes Symbol.for("two.words")
syms.twoWords
becomes Symbol.for("two.words")
syms.TwoWords
becomes Symbol.for("two.words")
syms.kTwoWords
becomes Symbol.for("two.words")
In short, the following:
const syms = require("syms");
const { kSomething, ANOTHER_THING, yetAnotherThing, ["A Fourth thing"]: THING4 } = syms;
const THING5 = syms["thing #5"]
// with a namespace:
const { example, kAnotherExample, EXAMPLE_THREE } = syms[syms.ns]('my.app.name')
Is equivalent to:
const kSomething = Symbol.for("something");
const ANOTHER_THING = Symbol.for("another.thing");
const yetAnotherThing = Symbol.for("yet.another.thing");
const THING4 = Symbol.for("a.fourth.thing");
const THING5 = Symbol.for("thing.5");
const example = Symbol.for("my.app.name.example")
const kAnotherExample = Symbol.for("my.app.name.another.example")
const EXAMPLE_THREE = Symbol.for("my.app.name.example.three")
JavaScript Symbol
objects are an incredibly handy generic construct in modern JavaScript which can be utilized for many purposes, including:
this[Symbol.for('perform-internal-action')]()
rather than something like this._performInternalAction()
JSON.stringify
-- JSON.stringify
will skip symbol-keyed entries when serializing objectsThere are two ways of constructing a symbol: Symbol("some-name")
or Symbol.for("some-name")
, the difference being that Symbol.for()
will always return the same symbol object when given the same key, while Symbol()
always returns a unique symbol object (in other words, Symbol("foo") !== Symbol("foo")
while Symbol.for("foo") === Symbol.for("foo")
). You can think of this library as Symbol.fuzzyFor()
.
In order to be clean with Symbol.for()
, it is helpful to namespace your keys with a unique prefix. For example, if you have a program named 'crayon box' and you want to define red
, green
, and blue
symbols, you may want to define these as Symbol.for('crayon.box.red')
, rather than Symbol.for('red')
, to keep your symbols from unintentionally colliding with another color management program.
A helper is provided for creating multiple symbols using the same prefix, accessed by syms[Symbol.for('ns')]("my.namespace")
or syms[syms.ns]("my.namespace")
:
const syms = require("syms");
const test = Symbol.for("one.two.three.four.five");
const {twoThreeFourFive: check1} = syms[Symbol.for('ns')]('one');
const {THREE_FOUR_FIVE: check2} = syms[Symbol.for('ns')]('one_two');
const {four_five: check3} = syms[syms.ns]('one :: two');
const {kFive: check4} = syms[syms.ns]('one/two/three');
assert.equal(test, check1);
assert.equal(test, check2);
assert.equal(test, check3);
assert.equal(test, check4);
The reason that .
is used as a word separator is because modern versions of node
use Symbol.for("nodejs.foo.bar")
style symbols, allowing things like this:
const syms = require("syms");
const sym1 = require("util").inspect.custom;
const sym2 = Symbol.for("nodejs.util.inspect.custom");
const { NODEJS_UTIL_INSPECT_CUSTOM } = syms;
const { nodejsUtilInspectCustom } = syms;
// with the `syms[syms.ns](namespaceName)` helper, you can do stuff like this:
const { inspectCustom } = syms[syms.ns]('nodejs.util');
// sym1, NODEJS_UTIL_INSPECT_CUSTOM, and nodejsUtilInspectCustom are all the same symbol, which is also the symbol returned by ``
const {strict:assert} = require("assert")
assert.equal(sym1, sym2)
assert.equal(sym1, NODEJS_UTIL_INSPECT_CUSTOM);
assert.equal(sym1, nodejsUtilInspectCustom);
assert.equal(sym1, inspectCustom);
class MyThing() {
[inspectCustom]() {
return "[[ my-thing instance ]]";
}
}
console.log(require("util").inspect(new MyThing()));
One handy usage is to "clean up" your public/official api, without actually restricting access to the actual underlying methods/properties, which can feel slightly nicer than naming like this._internalThing
.
const { SEND, OUT_STREAM } = require("syms");
class Whatever {
constructor({ out = process.stdout }) {
this[OUT_STREAM] = out;
}
async doSomething() {
await someOperation();
this[SEND]();
}
[SEND]() {
this[OUT_STREAM].write("i'm sending you a message, friend, and i hope you receive it swiftly!\n");
}
}
In the above, you could could change these vars to kSend
+kOutStream
, or
send
+outStream
, or whatever other format pleases you. You could also use
const $ = require("syms")
and use this[$.outStream]
. Consumers of a Whatever
instance (const whatevs = new Whatever({out});
) can easily call whatevs[Symbol.for("send")]()
and whatevs[Symbol.for("out stream")]
, without even having to know that
you're using this library, and it would hopefully be pretty obvious that they're
reaching into your internal / non-official / non-stable APIs and should do so at
their own risk:
const out = fs.createWriteStream("/tmp/useless-file.txt");
const _send = Symbol.for('send');
const _outs = Symbol.for('out.stream');
const whatever = new Whatever({out})
whatever[_send]();
whatever[_outs].write("hello");
FAQs
Automatic/Convenience/Syntactic-Sugar Symbol.for() access: `const {WHATEVER,Vars,youWant} = require("syms")`
The npm package syms receives a total of 5 weekly downloads. As such, syms popularity was classified as not popular.
We found that syms demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.