Comments (2)
The named arguments feature was (is?) an experiment. I asked myself how would you access an object's properties, then noticed it was already implemented in Python, so I did something similar.
The implementation supports keys as generic ASCII variable names. For variable names, JavaScript - like many other languages - supports special characters like devanagari or cyrillic symbols. There are a few exceptions regarding reserved keywords, but generally speaking it supports just about any letter. In addition to that, it also allows for the $
sign.
Now, regarding objects keys, I assume it supports just about everything that fits into a string, right? That includes things like .
, [
, ]
, (
, )
and %
that I think would totally break the parser.
But suppose we reimplement the parser so that it consumes named arguments character by character and, somehow, gets past those shortcomings. Moving forward, suppose you have a format like %(foo.bar[baz])s
. How many properties does it reference: 1, 2 or 3?
That being said, currently I'm not really sure about your proposal. I think it would benefit if we added the $
character. I myself use it inside variable names and this one's easy. It might also benefit if we added support for Unicode characters - how?
Beyond that, any other character raises questions I'm not sure I want to ask, let alone answer.
from sprintf.js.
Also, I think adding them to the index access option would raise a couple of problems as well, which is why it's limited to natural numbers only.
from sprintf.js.
Related Issues (20)
- localization, internationalization decimal-separator HOT 1
- Missing unit tests for specifiers: a, A, E, F
- pi is hardcoded in unit tests HOT 1
- gulp jobs test, dist & default fail on node v13 HOT 2
- Remove browser .repeat polyfill requirement HOT 2
- unexpected placeholder when using object literal syntax HOT 2
- Unexpected %x behavior with negative HOT 2
- Padding with custom char fails HOT 1
- Boolean number throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) HOT 1
- provide padding examples HOT 1
- Issue with format %s using a width in several languages HOT 8
- How can I include Laravel in my project? HOT 1
- Is there a ESM version? HOT 17
- Support "%*s" as a format string
- Licensing Question HOT 9
- Long integer format specifier doesn't work: %ld HOT 1
- hx specifier doesn't work HOT 3
- Conversion error on large number (> 32bit) HOT 3
- print nothing on %n HOT 4
- [feature request] BigInt support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sprintf.js.