New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

syms

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syms

Automatic/Convenience/Syntactic-Sugar Symbol.for() access: `const {WHATEVER,Vars,youWant} = require("syms")`

  • 1.0.2
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

syms - easy Symbol.for access

This is an incredibly simple wrapper around Symbol.for() using a Proxy object.

In short, the following:

const { Something, ANOTHER_THING, yetAnotherThing, ["A Fourth thing"]: THING4 } = syms;
const THING5 = syms["thing #5"]

Is equivalent to:

const Something = Symbol.for("Something");
const ANOTHER_THING = Symbol.for("ANOTHER_THING")
const yetAnotherThing = Symbol.for("yetAnotherThing")
const THING4 = Symbol.for("A Fourth Thing")
const THING5 = Symbol.for("thing #5")

This is just an object, where for any requested property, Symbol.for(x) is returned, where x is the property name. The entire motivation for this module is that I tend to prefer using Symbols for "internal" methods/properties/etc, and that const {WHATEVER, WHATEVER_ELSE} = require("syms") feels fairly convenient.

Reasoning

Future/Modern ES* standards include/propose a #-prefixed notation for "private" class data -- this module is intended as an alternative for that, where the primary concern isn't "private" vs "public", but "internal" vs "external", and access to this variable is not a question of "do I have permission" vs "do I know that what I'm doing is recommended usage or not".

In RFC terms, this is meant for properties which the user SHOULD NOT use, rather than those that the end-user MUST NOT use.

In other words, what this module communicates isn't "is this public or private", but rather "is this supported or unsupported" by your API.

Keywords

FAQs

Package last updated on 16 Dec 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc