nbubna / case Goto Github PK
View Code? Open in Web Editor NEWString case utitility: convert, identify, flip, extend
Home Page: http://nbubna.github.io/Case/
License: MIT License
String case utitility: convert, identify, flip, extend
Home Page: http://nbubna.github.io/Case/
License: MIT License
I noticed that the first and last words from a Case.title
call are not uppercased if they are a small word. I think this should be dealt with internally.
This is a pretty good implementation of title casing for reference.
As well as the first letter, sentence case strings can contain capital letters in cases such as proper nouns and acronyms.
For example, this title should be identified as sentence case: "Skin microbiota in frogs from the Brazilian Atlantic Forest: species, forest type, and potential against pathogens".
I just stumbled upon this issue:
If I have a string like "Room", Case.of()
returns capital
.
If I turn it into a pascal string (which it already is) and then get the case of that Case.of(Case.pascal('Room')
, it still returns capital
.
I think there is some kind of configuration needed on how to handle single word strings, because those are ambiguous. I could propose a PR if you like.
Case is published on NPM stating the License is: MIT OR GPL-3.0-or-later
while the license text on github is MIT
. Please update the NPM registration accordingly.
Hi,
Strange behavior when (No) is there in string.
E.G.
title("ABC (No)") // ABC (No)
title("ABC (NO)") // Abc (No)
title("ABC (NT)") // Abc (Nt)
title("ABC (XX)") // Abc (Xx)
Same with capital, I haven't checked other.
Hope to resolve soon.
Case.of('foo') -> 'snake'
Lets say I have something formatted from numeral.js.
var m = 1.40m;
m = case.upper(m)
console.log(m) //will yield 1 40M , how do I ignore the period remeoval?
Also yes I know I could use the last char.upper() , that is besides the point.
Possible solution: detect if submitted string is actually text not numeral.
Quite messy in Javascript as per https://stackoverflow.com/questions/1027224/how-can-i-test-if-a-letter-in-a-string-is-uppercase-or-lowercase-using-javascrip?noredirect=1&lq=1
In doing a license audit, Case reports both MIT and GPL.
Anything that includes or links to GPL inherits GPL terms, therefore making the entire Case package viral. You also list MIT which is non-viral, but the GPL virally overrides the MIT terms.
Do you intend for Case to be GPL (viral), or MIT? Or, is Case subject to a sub-component / code snippet that carries GPL?
$ npm install case
[email protected] node_modules/case
$ node
> require('case')
ReferenceError: window is not defined
at Object.<anonymous> (/home/ubuntu/playground/node_modules/case/dist/Case.js:125:18)
at Object.<anonymous> (/home/ubuntu/playground/node_modules/case/dist/Case.js:128:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
I guess the problem lies on these 2 lines.
Hey there. Thanks for this awesome library.
The Rails inflector supports user-defined acronyms, so that http_client
could be transformed into HTTPClient
(for example). See https://github.com/rails/rails/blob/f2489f493b794ee83a86e746b6240031acb8994e/activesupport/lib/active_support/inflector/inflections.rb#L78 for details.
I may have time in the near future to implement this. Would you accept a PR if I did?
At first I thought it was because of this 2ee18f3#commitcomment-9465980 but I see that its not now. Instead it appears that the export type has changed from being an object of functions to a two-layer nested object structure, see:
It's breaking words...
> Case.upper('résumé')
'R SUM'
Hi,
Passing in an empty string into the sentenceCase filter generates an error "Unable to get property 'replace' of undefined or null reference".
After stepping thru the code, I believe the culprit is the modifications to the fill functions at this commit 3289456#diff-6f9cd8468dcb32af7249d8e02dd3ab07.
Previously, you would return 's' if !s === true, however in the latest you do not return anything, causing it to return undefined.
-Taylor
It looks like this is licensed under the MIT License, but NPM doesn't reflect that: https://www.npmjs.com/package/case
Is it possible to publish this package to NPM with the license specified? We have automatic license validation that blocks the use of this package without it.
Thanks!
in node require('case')
works.
in the browser require('case')
doesn't, you gotta do require('Case')
for it to work.
Edited typo
It will turn -30
into 30
.
Oddly enough it works fine if there is another word such as -30 degrees
[email protected]
[email protected]
$ node
> const case = require('case')
...
...
...
# hangs forever, have to ctrl+c out
> require('case').title('hello') # this works for some reason
'Hello'
This is correct :
Case.camel('This is a test') === "thisIsATest"
But the contrary seems unexpected :
Case.upper('thisIsATest') === "THIS IS ATEST"
Case.lower('thisIsATest') === "this is atest"
and the same goes for other manipulations
https://nodejs.org/api/esm.html#esm_conditional_exports
Add support for esm.
If you think this proposal is reasonable, I'll create a PR for this.
Title turns I'm
into I'M
.
Also it will turn -30
into 30
.
Oddly enough it works fine if there is another word such as -30 degrees
Thanks for this great library! However, this is the first time I have run into a case were something was not as expected.
See the below:
const changeCase = require('change-case');
const Case = require('case');
console.log(Case.constant('crapP4')) // ===> 'CRAPP4'
console.log(changeCase.constant('crapP4')) // ===> 'CRAP_P4'
I believe changeCase is correct.
On https://www.npmjs.com/package/case, license field is showing as "none", I think NPM cannot parse LICENSE-MIT file. Other variations such as LICENCE, LICENSE.md are accepted.
I suggest renaming LICENSE-MIT to one of these variations if possible.
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.