ephetic / checked-constants Goto Github PK
View Code? Open in Web Editor NEWGrepable typo-resistant namespaced constants
Grepable typo-resistant namespaced constants
Frozen objects and getters that throw could do a lot of the same. Could be grepable with a definition syntax that enforced symmetry between definition and reference:
const cc = require('@ephetic/checked-constants')
cc.foo.bar.somekey = 111
where cleverness in cc allows the chain of previously undefined namespaces to be created. Would need a way to prevent grabbing object references at partial/parent paths of valid namespaces that are not themselves valid namespaces (e.g. cc.foo
in previous). Would need way to keep cc extensible without namespaces being mutable, akin to #5.
If a namespace can be added to anywhere, some of the desired explicitness is lost. Perhaps there should be a restriction that each namespace can only be written to once, thus requiring all constants in that namespace to be in a single multiple definition.
Alternately, if the definition syntax is sufficiently grepable that dispersed definitions are as easily found as their references, then it isn't a problem.
e.g.
const ns = cc.using('my/namespace')
ns`frobulate`
Given a module that uses this library, how would it announce to its users what constants are available? Traditionally this would be via documentation, but enums and constants objects would have tool support making this easier.
e.g.
const cc = require('checked-constants')
const ns = cc.isolated()
cc`foo/bar${'global'}`
ns`foo/bar${'distinct'}`
cc`foo/bar' //=> 'global'
ns`foo/bar' //=> 'distinct'
Will require packages.json changes and would be a good time for src/test refactoring.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.