Giter Club home page Giter Club logo

voca's Introduction

Voca JavaScript library logo

travis build code coverage npm package

Voca is a JavaScript library for manipulating strings. https://vocajs.pages.dev

v.camelCase('bird flight');              // => 'birdFlight'
v.sprintf('%s costs $%.2f', 'Tea', 1.5); // => 'Tea costs $1.50'
v.slugify('What a wonderful world');     // => 'what-a-wonderful-world'

The Voca library offers helpful functions to make string manipulations comfortable: change case, trim, pad, slugify, latinise, sprintf'y, truncate, escape and much more. The modular design allows to load the entire library, or individual functions to minimize the application builds. The library is fully tested, well documented and long-term supported.

Features

  • Provides the complete set of functions to manipulate, chop, format, escape and query strings
  • Includes detailed, easy to read and searchable documentation
  • Supports a wide range of environments: Node.js 0.10+, Chrome, Firefox, Safari 7+, Edge 13+, IE 9+
  • 100% code coverage
  • No dependencies

Documentation

See the complete documentation at https://vocajs.pages.dev

Usage

Voca can be used in various environments.

Node.js, Rollup, Webpack, Browserify

Voca JavaScript library supports Node.js, Rollup, Webpack, Browserify

Install the library with npm into your local modules directory:

npm install voca

CommonJS modules

Then in your application require the entire library:

const v = require('voca');
v.trim(' Hello World! ');            // => 'Hello World'
v.sprintf('%d red %s', 3, 'apples'); // => '3 red apples'

Or require individual functions:

const words = require('voca/words');
const slugify = require('voca/slugify');
words('welcome to Earth'); // => ['welcome', 'to', 'Earth']
slugify('caffé latté');    // => 'caffe-latte'

ES2015 modules

Voca is compatible with ES2015 modules to import the entire library:

import voca from 'voca';
voca.kebabCase('goodbye blue sky'); // => 'goodbye-blue-sky'

Or import individual functions:

import last from 'voca/last';
last('sun rises', 5); // => 'rises'

Browser

Voca JavaScript library supports Chrome, Firefox, Safari, Edge, Internet Explorer

Load the UMD builds directly into browser's web page:

<script src="voca.js" type="text/javascript"></script>

Then a global variable v is exposed for the entire library:

<script type="text/javascript">
  v.last('wonderful world', 5); // => 'world'
</script>

Functions

Manipulate Query Chop Case Index
v.insert v.endsWith v.charAt v.camelCase v.indexOf
v.latinise v.includes v.codePointAt v.capitalize v.lastIndexOf
v.pad v.isAlpha v.first v.decapitalize v.search
v.padLeft v.isAlphaDigit v.graphemeAt v.kebabCase Escape
v.padRight v.isBlank v.last v.lowerCase v.escapeHtml
v.repeat v.isDigit v.prune v.snakeCase v.escapeRegExp
v.replace v.isEmpty v.slice v.swapCase v.unescapeHtml
v.replaceAll v.isLowerCase v.substr v.titleCase Strip
v.reverse v.isNumeric v.substring v.upperCase v.stripBom
v.reverseGrapheme v.isString v.truncate Split v.stripTags
v.slugify v.isUpperCase Count v.chars
v.splice v.matches v.count v.codePoints
v.tr v.startsWith v.countGraphemes v.graphemes
v.trim Format v.countSubstrings v.split
v.trimLeft v.sprintf v.countWhere v.words
v.trimRight v.vprintf v.countWords
v.wordWrap

Bug reports

For bug reports, documentation typos or feature requests feel free to create an issue.
Please make sure that the same problem wasn't reported already.

For general usage questions please ask on StackOverflow.

Contributing

Contribution is welcome!

  • Create a pull request containing bug fixes or new features. Include unit tests and keep the code coverage report near 100% 😎
  • Propose new functions, improvements, better documentation

See more details in Contributing guide.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Author

Dmitri Pavlutin
Dmitri Pavlutin
Personal blog
Email

License

Licensed under MIT

voca's People

Contributors

2857 avatar alexandra-pavlutin avatar ejnahc avatar kylejsummers avatar panzerdp avatar posixpascal avatar timgates42 avatar xdamman 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voca's Issues

[Feature Request] Pascal Case

Hi,

Great lib! Is there not a pascal case function? Didn't see it in docs or issues but I'm surprised. I assume it could easily be done like this:

v.chain('my thing').camelCase().capitalize().value() // -> 'MyThing'

Would a PR be accepted for this?

Change required for v1.4.1

Just a note for your v1.4.1 release notes - I had to make the following change:

// v1.4.0
window.v = require('voca');

// v1.4.1
window.v = require('voca').default;

Any plans to handle encodings?

I think this library should include functions to convert Strings to TypedArrays and viceversa, with the option to interpret as UTF-8 or UTF-16 depending on use case. So if a string is to be interpreted as UTF-8, the corresponding TypedArray should be a Uint8Array, otherwise UTF-16 is used and a Uint16Array of code-units is returned. If an arbitrary TypedArray is provided, it'll be read as a string of octets, and those octets will be converted to a string depending on the chosen encoding. UTF-16 has endianess and BOMs, so a function that handles implicit and explicit endianess would be slightly more complicated.

Another thing related to encodings are binary-to-text encodings like Hexadecimal, base64, base85, etc. JS already has base64 support with atob and btoa, but hex and base85 are missing, which could be provided by this library.

I don't know if these features should be added to this library because Voca seems to be intended for high-level (not low-level) use cases, and adding base85 support would be pointless because it's rarely used. Any constructive criticism is appreciated

Reverse argument order

This is quite a big suggestion, but in my opinion the order of the arguments is inconsistent across functions, and generally the wrong way around.

See these for details:
http://functionaltalks.org/2013/05/27/brian-lonsdorf-hey-underscore-youre-doing-it-wrong/
https://jsleao.wordpress.com/2015/02/22/curry-and-compose-why-you-should-be-using-something-like-ramda-in-your-code/

There are some cases where API is the right way around, and would allow for currying or partial application:

v.sprintf('%s costs $%.2f', 'Tea', 1.5);

Here, you take config first, data last, which is the "right way". This allows you to things like:

const logMyStuff = v.sprintf.bind(null, "%s costs $%.2f")
logMyStuff("Tea", 1.5)
logMyStuff("Coffee", 2.40)

which allows you to use this function in compose chains, for example.

You cannot do that with this function:

v.replaceAll('good morning', 'o', '*');

If the order were reversed, and currying implemented, you could do this:

const changeOsToStars = v.replaceAll("o", "*")

And now you have a function you can use over and over.

With the use of FP (and in particular partial application and currying) on the rise in JavaScript, I think this library should take a leaf from ramda's book and put config first, data last, and curry by default.

Thoughts?

Custom build tool

Voca library needs a custom build tool to generate configured builds.

Rough the command npm run build should implement the following settings:

  • Accept the list of functions that must be included,
    e.g. --functions sprintf,camelCase,insert,latinise
  • Accept the list of function categories that must be included,
    e.g. --categories escape,format
  • Accept the list of functions that must be excluded (used in combination with categories),
    e.g.--exclude-functions insert,latinise
  • Accept an exported format cjs (CommonJS), umd (Universal Module Definition), iife, es,
    e.g. --format cjs
  • Accept a minification parameter,
    e.g. --minify
  • Accept a FP build parameter:
    e.g. --fp
  • Accept an output file path parameter:
    e.g. --output dist/voca.cust.build.js

For instance the following command creates a fp build exported as CommonJS of sprintf() and latinise() functions:

npm run build --functions sprintf,latinise --format cjs --fp

explorer support

Hi! I tried the voca.js on explorer v11 and it crashed.

I'm not an expert in javascript but I managed to make it work by adding a few lines. Maybe it could be useful to others?

Modifies:

At the very beginning of the file:

//object.keys support
if (!Object.keys) {
  Object.keys = function(obj) {
    var keys = [];
    for (var i in obj) {
      if (obj.hasOwnProperty(i)) {
      keys.push(i);
    }
  }
 return keys;
  };
}

//object.values support
if (!Object.values) {

Object.values = function(obj) {

var res = [];
    for (var i in obj) {
        if (obj.hasOwnProperty(i)) {
            res.push(obj[i]);
        }
    }
    return res;
  };
}

//Array.foreach support
if (!Array.prototype.forEach) {
    Array.prototype.forEach = function(fn, scope) {
        for(var i = 0, len = this.length; i < len; ++i) {
            fn.call(scope, this[i], i, this);
        }
    }
}

//Array.isArray support
if (!Array.isArray) {
    Array.isArray = function(item) {
      if(item instanceof Array){return true;}
      return false;
    }
}

//bind support
if (!Function.prototype.bind) {
  Function.prototype.bind = function(oThis) {
    if (typeof this !== 'function') {
      // closest thing possible to the ECMAScript 5
      // internal IsCallable function
      throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
    }

    var aArgs   = Array.prototype.slice.call(arguments, 1),
        fToBind = this,
        fNOP    = function() {},
        fBound  = function() {
          return fToBind.apply(this instanceof fNOP && oThis
                 ? this
                 : oThis,
                 aArgs.concat(Array.prototype.slice.call(arguments)));
        };

    fNOP.prototype = this.prototype;
    fBound.prototype = new fNOP();

    return fBound;
  };
}

(function (global, factory) { 
[...]

And then the function isNil

function isNil(value) {
    return value === undefined || value === null || value === '';
}

Now it works.

Optimization Interests?

Scripts are cool for frontend.
But serverside needs performance.

Chaining the string methods practically causes reloops per chain.

How about synthesizing methods together for one loop?

Starting the project in a few a days.

Strip HTML from Text

Awesome library, would have a suggestion.
v.stripHtml(htmlTagArray = [''])

If any htmlTag is given within the array the strip function is limited to them otherwise the function removes all html tags.

Can I know how to integrate vocajs with angular?

Welcome to Voca's GitHub repo!

Expected behavior 😸

(Please describe here the expected behavior)

Actual behavior 😿

(Please describe here the actual behavior)

Steps to reproduce 👷

(Please describe a scenario how to reproduce)

Technical details: 🔧

Browser/OS type:
Node version:

Typo in example for lowerCase method

Documentation example shows:

v.lowerCase('BLUE');
// => 'BLUE'

which should be

v.lowerCase('BLUE');
// => 'blue'

I am about to submit a pull request for this fix, albeit quite small. In the future, for small documentation changes such as these, do you prefer just an issue or do you welcome pull requests?

Thanks!

keepAfter, keepBefore, keepBetween, keepChars

Hi, this is a feature suggestion to this awesome library.

The suggested functions are as follows:

  • keepAfter(text, after_string, instance_num*)
  • keepBefore(text, before_string, instance_num*)
  • keepBetween(text, keep_start, keep_end)
  • keepChars(text, keep_string)

*optional arguments

These are inspired by a program called EasyMorph. And for more info I'll link to their documentation.

keepAfter

This function returns characters after the first occurrence of after_string in text, if found. If after_string is not found within text and "empty" value is returned.

keepAfter('a/b/c/d', 'b') //Returns '/c/d'

More info

keepBefore

This function returns characters before the first occurrence of before_string in text, if found. If before_string is not found within text and "empty" value is returned.

keepBefore('5pm', 'pm') //Returns '5'

More info

keepBetween

This function returns the characters between the first occurrence of keep_start and the first occurrence of keep_end in text.

keepBetween('Mary Joe Smith', 'Mary ', ' Smith') //Returns 'Joe'

More info

keepChars

This function keeps only the characters given in keep_string and removes the others from text.

keepChars('a1b2c3', 'abc') //Returns 'abc'

More info

Title Abbreviations

Welcome to Voca's GitHub repo!

Expected behavior 😸

When title casing an abbreviation, I would expect the abbreviation to be preserved.

voca.titleCase("HTML is Awesome") // => "HTML is Awesome!"
voca.titleCase("JS is Cool") // => "JS is Cool"

I expect Voca's titleCase function to respect all title rules. Maybe this warrants a separate function or an additional option?

Actual behavior 😿

Instead, Voca converts these words

voca.titleCase("HTML is Awesome") // => "Html is Awesome!"
voca.titleCase("JS is Cool") // => "Js is Cool"

Steps to reproduce 👷

Call the functions as described above.

Technical details: 🔧

Browser/OS type: macOS 10.15.3
Node version: 13

Improved regular expression to match words

The regexp that matches words works correct for most of the cases. However the regexp is too heavy because it enumerates a lot of unicode character code points.

A lighter alternative is necessary to implement.

Using the updated python format syntax

Hey panzerdp,

Thanks for this library! I looked through your tests for format. It looks like it is using the old c % format syntax. Is there plan on supporting the new {:03d} kind of string format?

Here is a helpful link for some of the things that are possible:

https://pyformat.info | using string.format() for great good

Sanitize logic

Expected behavior 😸

Hello, I want to migrate from String.js older (but very important code) used tu sanitize string in our apps but I can't recreate the same usage with voca.

Actually I use this with string.js :

S(text).trim()
        .latinise()
        .humanize()
        .stripPunctuation()
        .underscore().s

And this is the result I want for this strings :

original sanitized
Volume chaudière & appoint volume_chaudiere_appoint
test___multi__underscore test_multi_underscore
Volume chaudière & appoint 12 volume_chaudiere_appoint_12
A 11yn a_11yn
Well k1 well_k1
test&12 test12
a & b a_b
a&b ab

This is really important to keep this sanitized format for us. Without it, all our application is broken for existing data.

Actual behavior 😿

Actually, I converted this function doing this :

snakeCase(latinise(text))

But I have problem with text with attached numeric and alphanumeric characters, or with special char between them :

original sanitized
A 11yn a_11_yn
Well k1 well_k_1
test&12 test_12
a&b a_b

I test many functions and I can't find any voca function to do our sanitized part

Steps to reproduce 👷

Pass the original texts into snakeCase(latinise(text))

Technical details: 🔧

Browser/OS type: directly in node 18
Node version: latest node 18 LTS

Support for converting possible boolean strings to actual boolean values

Support for converting the boolean type of string to actual boolean

Converting the logical booelan strings to respective booleans
v.boolean('true');
// => true
v.boolean('1');
// => true
v.boolean('yes');
// => true
v.boolean('false');
// => false
v.boolean('0');
// => false
v.boolean('no');
// => false

The comparisons are case insensitive
The list of truth values we can consider -> 'true', true, '1', 1, 'yes', 'on'

If this is fine I will submit a pull request for this function implementation.

New manipulation method: pluralise

Hey there! I've been using voca heavily in an app, however I had to create a plural function for a few places that voca couldn't help with. Since it's a simple helper and seemed to fit in with the other manipulation methods like capitalise() I thought it might be worthy addition to the library.

Pluralises strings, given a subject and an amount.
Also takes an optional plural string for deviations/uncommon plurals.

v.pluralise('dog', 0);
// => 'dogs'
v.pluralise('dog', 1);
// => 'dog'
v.pluralise('dog', 2);
// => 'dogs'
v.pluralise('dog', -4);
// => 'dogs'
v.pluralise('wolf', 1, 'wolves');
// => 'wolf'
v.pluralise('wolf', 42, 'wolves');
// => 'wolves'

Check List

  • [:heavy_check_mark:] All tests passed
  • [:heavy_check_mark:] Added tests to ensure correctness
  • [:heavy_check_mark:] Added jsdoc annotations

Can view the changes here if you'd like me to make a proper PR.
https://github.com/DJTB/voca/commit/0ee27311feca765711cb30bc008d29032cc44829

from "import v from 'voca'" to "'import * as v from 'voca'"

Just upgraded my Angular2+ (5) app to latest packages and my voca (which I didn't upgrade) includes call stopped being recognised. I needed to change import v from 'voca' to import * as v from 'voca'.

Might be worth investigating/updating your docs.

Thanks for the brilliant library.

behave of camelCase with a number

When camelCase with special characters, the characters will be removed.

But when I camelCase with a number, the number will not be removed and the letter next to the number will be capitalized. I am not sure the behave is correct or not.

version: 1.0.0

example:

v.camelCase("BIRD1FLIGHT")
//=> "bird1Flight"

v.camelCase("bird-1flight")
//=>"bird1Flight"

v.camelCase("bird-1flight-111-1--bi4rd 1flight")
//"bird1Flight1111Bi4Rd1Flight"

Default regex for words treats numbers as individual words

I am unsure if this is behavior is intended or not but if there is a number that is part of word or acronym it is broken out as a separate word.

Expected behavior:

v.words('What Is The Best MACD Indicator for MT4?')
(8) ["What", "Is", "The", "Best", "MACD", "Indicator", "for", "MT4"]

v.countWords('What Is The Best MACD Indicator for MT4?')
8

Current behavior:
v.words('What Is The Best MACD Indicator for MT4?')
(9) ["What", "Is", "The", "Best", "MACD", "Indicator", "for", "MT", "4"]

v.countWords('What Is The Best MACD Indicator for MT4?')
9

I realize I could come up with my own regex to solve this issue but the default regex works really well besides this one scenario which doesn't seem intended.

I am using Voca 1.4.0

titleCase behaviour with prime/apostrophe

Expected behavior 😸

v.titleCase("professor's office")
'Professor\'s Office'

Actual behavior 😿

v.titleCase("professor's office")
'Professor\'S Office'

Node version: 8.1.4

Are there situations that I'm missing here where a letter after a prime/apostrophe should be capitalized?
The same behaviour occurs with real/smart quotes ( as opposed to ') as well

> v.titleCase("professor’s office")
'Professor’S Office'

No publishing updates on NPM/Yarn?

Welcome to Voca's GitHub repo!

Expected behavior 😸

When a codebase has a significant change in GitHub, there should be something published to NPM/Yarn so people can take advantage of those updates through their package manager.

Actual behavior 😿

There hasn't been a publishing of this library to NPM/Yarn in over 2 years.

Steps to reproduce 👷

https://www.npmjs.com/package/voca?activeTab=versions
https://yarnpkg.com/package/voca

Technical details: 🔧

Not relevant. I was really looking at this as a serious solution for cutting accent characters at my work, but I'm concerned of this not being published to any package management tools in so long. Awesome work on this library, either way. There's some very useful methods here that I would love to use.

Voca's title case function is capitalizing some words it shouldn't

Expected behavior 😸

When title casing an abbreviation, Voca capitalizes some words it shouldn't, like to or a. I realize this can get pretty complicated or can vary between styles, but it seems to me that it still be helpful to have a function that followed the general rules.

voca.titleCase("bruce willis is a badass") // => "Bruce Willis is a Badass"

Actual behavior 😿

Voca capitalizes those words.

voca.titleCase("bruce willis is a badass") // => 'Bruce Willis Is A Badass'

Steps to reproduce 👷

Call the functions as described above.

Technical details: 🔧

Browser/OS type: macOS 10.15.3
Node version: 13

Error in function getGlobalObject in ./node_modules/voca/index.js:3595

Welcome to Voca's GitHub repo!

Expected behavior 😸

Importing the library should not throw an exception.

Actual behavior 😿

Following exception is thrown:

global is not defined

Error in function getGlobalObject in ./node_modules/voca/index.js:3595

 3593 |   if (typeof global === 'object' && global.Object === Object) {
 3594 |     // NodeJS global object
> 3595 |     globalObject$1 = global;

Steps to reproduce 👷

This seems to be an issue using voca in the latest major update of Gatsby (v3), or perhaps Webpack?
From what I can gather, voca is initialising the global object using "global" (ie NodeJS instance) even though this is a browser instance, I don't understand why it would be entering that if statement

Technical details: 🔧

Browser/OS type: Chrome/ Ubuntu 20
Node version: v12.21.0

Voca doesn't handle complex characters like కృష్ణ

Welcome to Voca's GitHub repo!

Expected behavior 😸

v.graphemes("కృష్ణ") should return (2) ["కృ", "ష్ణ"]
v.countGraphemes("కృష్ణ") should return 2

Actual behavior 😿

v.graphemes("కృష్ణ") returns (5) ["క", "ృ", "ష", "్", "ణ"]
v.countGraphemes("కృష్ణ") returns 5

Steps to reproduce 👷

v.graphemes("కృష్ణ")
v.countGraphemes("కృష్ణ")

Technical details: 🔧

Browser/OS type: n/a
Node version: n/a

v.padLeft('bird', 6, '-'); in document tells result should be '--bird-', but browser result is "--bird"

Welcome to Voca's GitHub repo!

Expected behavior 😸

in document
https://github.com/panzerdp/voca/blob/master/src/manipulate/pad_left.js
https://vocajs.com/#padLeft
shows:

v.padLeft('bird', 6, '-');
// => '--bird-'

Actual behavior 😿

v.padLeft('bird', 6, '-');

resrult:
"--bird"

Steps to reproduce 👷

  1. brower access voca official document and open dev mode.
  2. tyep: v.padLeft('bird', 6, '-');

Technical details: 🔧

Browser/OS type: firefox/chrome

comments

The document should be the mistake by my understand.

Reverse camelcase?

I like Voca better than the alternatives, but I can't see how you would convert camelcase into words. In other libs it's called .humanize

For example:

"camelCase" -> "camel case"

v.template() function

v.sprintf() function works for many template requirements, but in some situations might be too heavy and complicated.

A simpler alternative v.template() function can have a lighter API, and work with arrays and objects.

[API in progress...]

Individual function cannot be imported with ESM imports

Expected behavior 😸

Individual functions import with ECMAScript modules work in browsers.

Actual behavior 😿

Global import using default export for voca is working:

import voca from 'voca';

However, individual function imports with ESM modules is not working:

Uncaught SyntaxError: The requested module '../node_modules/voca/starts_with.js' does not provide an export named 'default'

Steps to reproduce 👷

import startsWith from 'voca/starts_with';

Technical details: 🔧

Browser/OS type: Chrome 67
VocaJS version: 1.4.0

Will you support IE8?

Hi. I think Voca is very good library for string control.

But, Voca is not support to IE8 currently.

I want to know if you will support IE8.

Feature Suggestion: Title Case

Feature Suggestion

Convert a string to title case.

Examples

v.titleCase('hello world')
// => 'Hello World
v.titleCase('Hello world')
// => 'Hello World
v.titleCase('hello World')
// => 'Hello World

Implentation Suggestions

This SO question has many suggestions.

The top answer uses string.replace() with regex:

function toTitleCase(str) {
  return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}

Not sure about the coverage of all cases.

Options

In formal title case, words like 'a', 'it', 'of', etc. are ignored (not capitalized). Consider this as an option.
v.titleCase(subject, allWords)

v.titleCase('this is a title of great proportions', true);
// => 'This Is A Title Of Great Proportions'
v.titleCase('this is a title of great proportions', false);
// => 'This is a Title of Great Proportions'

Title Case feature is wrong

Hi,

The Title Case implementation doesn't follow proper rules for this case. In the original feature-request #21 these rules where explained but it seems somehow they didn't go into the implementation.

A description of those rules can be seen on:
https://www.bkacontent.com/how-to-correctly-use-apa-style-title-case/

Here is an example from New York Times. (More in the fiddle)

Expected behavior 😸

From Obama and Baker, a Lament for a Lost Consensus

Actual behavior 😿

From Obama And Baker, A Lament For A Lost Consensus

Steps to reproduce 👷

I've created this fiddle:
https://jsfiddle.net/Qcho86/h97y0vfq/

Technical details: 🔧

Here is a reference implementation by John Resig, the creator of jQuery.
https://johnresig.com/blog/title-capitalization-in-javascript/
https://johnresig.com/files/titleCaps.js

As you can see in the fiddle Resig's implementation is not perfect either.

From that page a list of edge cases to take into account:
https://daringfireball.net/projects/titlecase/examples-edge-cases

New way of string formatting

Hello!

What do you think about idea of implementing such formatting?

If we would name this function format, then here are some examples of how it would work:

v.sformat('{}, {}, {}', 0, 1, 2); => '0, 1, 2'
v.sformat('{0}, {0}, {1}, {2}, {3}', 1, 2, 3, 5); => '1, 1, 2, 3, 5'
v.format('{name}: {a}+{b}={c}', {name: 'sum', a: 1, b: 2, c:3}); => 'sum: 1+2=3'

There would be also possibility to pass function to format.

If you think this is a good idea, then I would implement it in the coming days 😄

RFC: Fuzzy compare function

Hi there!

Would you be interested in a function that matches two strings while ignoring diacritics and non-alphanumeric characters? Something similar to https://github.com/dar5hak/equalsish?

Example

v.fuzzyCompare("Some String", "somestring") === true

If so, I would be glad to send a pull request.

Implement countWords

Hi, congrats with 1.0. First small feedback. When I was browsing Count section I expected to see function to count words which is often used, for example, to generate approx "time read" time.

P.S. could you provide simple plan with some cool links to get started with modern iOS dev and Swift 3 for someone with a huge dev experience in general already? How do you handle env, config, styles, layout, package management? I don't like writing a lot of small UI classes and drag'n'dropin' UI with mouse, if there are packages to use something close to CSS/HTML would be great. May be you can follow me back on https://twitter.com/mevrael so I could DM you : )

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.