Coder Social home page Coder Social logo

js-capitalize's Introduction

Hi

I'm Stephen, a full-stack-ish developer working at a company called Dropscan. I do a lot of React & Typescript, as well as Rails, infrastructure and whatever else needs to be done.

Most of my open-source projects are pretty much unmaintained though I do try to check issues ~monthly. E-mail me if you really need my attention.

js-capitalize's People

Contributors

6akcuk avatar coleww avatar grncdr avatar imayolas avatar marceuy avatar sergejkaravajnij avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

js-capitalize's Issues

Add tests

You have example tests in the README, but none in the repository?

Feature Request: Keep minor words in lowercase

I know this is very complicated, but at least we can support a simplified version: lowercase all articles (a, an, the), coordinating conjunctions (and, or, but, …) and (short) prepositions (in, on, for, up, …). This should at least help with a decent amount of not grammar-focused computer science use cases

reference: https://titlecaseconverter.com/

Capitalises first letter in ordinal string (e.g. 1St, 2Nd, 3Rd)

I'm trying to use this package across a range of strings which on occasion include written ordinal numbers e.g. 1st time, 2nd time, 3rd time.

This unfortunately returns 1St Time, 2Nd Time, 3Rd Time.

I'm willing to have anyone challenge otherwise here but I can't really see a use case for this so i'm proposing that strings starting with numbers are excluded.

(Or at least provide an optional parameter for it?)

Issues with quotes

Here are some test cases for the issues. First test case is what you have in the README. Second and third test cases are the issues.

var capitalize = require('capitalize')

var test = require('tape')

test('Quotes test case 1', function(t) {
    t.plan(1)
    t.equal(capitalize.words("it's a nice day"), "It's A Nice Day")
})

// This becomes: It’S A Boy
test('Quotes test case 2', function(t) {
    t.plan(1)
    t.equal(capitalize.words("It’s a Boy"), "It’s a Boy")
})

// This becomes: 'there's Angels Among Us'
test('Quotes test case 3', function(t) {
    t.plan(1)
    t.equal(capitalize.words("'There's angels among us'"), "'There's Angels Among Us'")
})

[Feature] Ignore certain words like un di

I wrote this quickly but your welcome to take it or change it.

const STRING_UP = (string) =>{ if (typeof string !== 'string') return; const avoid = ['di','un']; let str = string.split(' '); let _s = ''; let max = str.length -1; str.forEach((s,i) =>{ if(avoid.find((_a) => _a === s)){ console.log('turd in punchbowl'); _s += s; if(i !== max) _s+= ' '; }else{ _s += s.toLowerCase().replace(/(^|[^a-zA-Z\u00C0-\u017F'])([a-zA-Z\u00C0-\u017F])/g, function (m) { return m.toUpperCase(); }); if(i !== max) _s+= ' '; } }); return _s; };

Publish to npm

Hey, #7 was merged almost a year ago but never published to npm, any chance you could cut a new version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.