GithubHelp home page GithubHelp logo

plexis's Introduction

Plexis

Lo-fi, powerful, community-driven string manipulation library.

This is the main monorepo codebase of Plexis.js a production-ready string manipulation library that's community-driven.

npm version bundle size CircleCI Codecov

What is Plexis?

Vision

For the past few years managing, contributing or even starting an open-source project could be hard, especially for newcomers. Plexis was born and driven by the JavaScript community. Our initial goal is to provide a production-ready set of utilities and help people understand how an open-source project is maintained. Plexis is driven by our contributors and it should always stay that way.

You may have noticed that some functions are missing and there are lots of open issues in our repo. That's because we want to allow people to create through the process of learning. Plexis grows with the community and we want to provide a friendly environment for people to get creative, have fun and expand their expertise into JavaScript.

Plexis aims to be the best and most flexible library for string operations in the JavaScript and also encourage everyone to learn.

Do you want to get your hands dirty? Learn more about contributing.

Docs

Installing

You may install Plexis by the registry using: npm install --save plexis. Plexis is a mosaic of tiny utility functions, each one lives within its own package inside the monorepo. Thus you may use just a tiny slice of Plexis by installing individual packages:

npm install @plexis/without-diacritics @plexis/toPred

Using

Plexis utilities can be directly used, Plexis is production-ready and made for Node.js as well as the web. You can directly include and use any module from Plexis inside your project.

import {toPred} from 'plexis';
console.log(toPred('A')); // B

Ground rules

All conversations code pieces on Plexis agree to our underlying code of conduct. This code of conduct also applies to all conversations that happen within our contributor community here on GitHub. We expect discussions in issues and pull requests to stay positive, productive, and respectful.

What you will learn by contributing

The basic idea behind Plexis is to help people understand and learn how to use the fundamentals of JavaScript. By contributing you get into:

  • Mastering JavaScript ES6.

  • Understanding how functions and closures work.

  • Understanding how strings and arrays work in JavaScript. You are gonna find yourself using Array.prototype.reduce() or Array.prototype.map() like a lot :)

  • Understanding how the NPM registry works, the anatomy of package.json and every single part of creating and publishing a package.

  • Working with pull requests, forks, GIT and the whole workflow of an open-source project.

  • Learning how unit testing works.

  • Taking a look at how a CI/CD workflow works along with the NPM registry.

Codebase and technologies

Ok, now let's talk about the architecture of this monorepo: Every single utility function exists as an independent package, everything comes together and gets bundled into a single source of truth, the main Plexis package.

Also, is a list of all the technologies and services we use:

  • Lerna: used for publishing and managing the monorepo packages.
  • Babel: used as a JavaScript compiler.
  • Jest: used for testing.
  • Yarn: used as a package manager.
  • JSDoc: used as a documentation manager.
  • CircleCi: used as a CI/CD provider.
  • Commitlint: used for linting our commit messages.
  • Prettier: used for code linting and formatting.

Folder structure

plexis/
├── .circleci         # CI/CD config
├── .circleci         # CI/CD config
├── .package-template # A sample package template
├── docs              # Our official documentation
└── packages          # The heartbeat of plexis

Contributing

We welcome any contributions from the community! Plexis is made, driven and maintained by the community. We want to offer everyone a fair chance to make their first steps into open-source and learn through the journey.

Great, how do I get started?

Plexis has a Code of Conduct. Please review and help enforce this code of conduct to help us foster an open and inclusive project.

How to Contribute

First things first, thanks so much! Feel free to contribute by opening and commenting on issues, helping answer questions, updating or improving our documentation, or opening a pull request. For quick bug fixes or PRs that address an open issue, feel free to open a PR. You can suggest API changes or dig through your codebase and make us a gift with that precious function of yours.

Even the tiniest piece of code, knowledge or even a few minutes you can spare for Plexis are really important for us. Code of Conduct

Creating a new issue

We have set up proper GitHub issue templates with guidelines about asking for features, fixing a bug or even questions. We are waiting for your ideas to start flowing.

Setup your environment

Ok, so you found the perfect issue for getting started. You can set up your working environment simply by installing git, Node.js, npm and yarn. Use your favorite IDE and you are ready to rock and roll. We prefer using VSCode along with a few extras:

  • The prettier extension for code formating
  • The Document this extension for JSDoc
  • The Jest extension for writing and managing tests.

Now you can locally clone the project as: git clone [email protected]:plexis-js/plexis.git. Use yarn to install any missing dependencies simply by typing yarn in your CLI.

Pick an open issue

Plexis is all about teaching people. You can found lots of open issues with different types of difficulty. Usually, there are labels that they can help you find the best open issue for you. Find the best issue for you and let's get started.

Usually, you will find yourself creating a new package or as it is said "a feature request", thus we are trying to provide as much information, test cases or examples as possible.

Writing code for Plexis

Plexis is using ES6 syntax at full speed. Plexis also uses the monorepo architecture. Every utility function is also a single entry package under the @plexis organization. Some prior knowledge of string operations, regular expressions or array operations are nice to have but certainly not required, we will learn and grow together.

Naming conventions

Each utility is named using the camelCase convention. Since our utilities are used for string operations you will spot a pattern of missing verbs upon naming our methods.

For example, a utility function that converts a string to camelCase can be named as toCamelCase, which references to text => transformToCamelCase => output. For convenience reasons the main Plexis packages also exports a few aliases like dasherize or titleize.

Creating a new package

If you want to create a new package we are on a great path 🎉. You need to take a few additional steps. Let's assume that you need to create a new package for the camelCase utility.

First thing first we need to create a new @plexis packages using lerna create @plexis/came-case. _Note: NPM does not allows uppercase characters for packages`.

You can use lerna create for creating a new package, more info can be found here. You should include all the available information for the new package like name, version, Alternatively, we are providing a template for new packages. Keep in mind that the name of package folders should be in camelCase and package.json details should be aligned with the other packages and lerna.json. For packages with dependencies to other @plexis packages, you can use yarn bootstrap which under the hood uses lerna bootstrap, learn more about bootstrapping here.

Afterward, create an src and a test folder, place your files and write the appropriate test cases for unit testing.

Note: Usually each package is a single function, thus the coverage limit is super easy to reach out, still, sometimes, we need to cover a lot of different cases due to feature's requirements.

A sample folder for camelCase would look like this:

packages/
├── ...
├── ...
└── toCamelCase/
    ├── src/
    ├── test/
    └── package.json

Finally, you should create a JSDoc comment block for your package, providing a proper description, some code examples and documenting the parameters passed through the function. You shall also create or update the README.md or any related documentation files.

Last but not least you shall update the main plexis package with exports all the submodules. Since the main plexis module uses snapshots for testing, you need to run yarn test -u to update the snapshot testing.

💡 Tip: If your pull request resolves an open issue, don't forget to use GitHub keywords in the description of your commit message, e.g., closes #1, to automatically close the equivalent issue upon merge.

Pull requests

In a nutshell, to submit a pull request, follow these steps:

  1. Fork and clone this repo,
  2. Create a branch for your changes.
  3. Install dependencies with yarn.
  4. Ensure tests are passing by running yarn test. Update any snapshots using yarn test -u.
  5. Update the docs or README.md file if required.
  6. If you're fixing a bug, it's recommended to write a failing test before writing any code.
  7. Make changes locally and commit them.
  8. Try to make sure tests still pass and that there's a great coverage and clear test cases.
  9. Push your branch to origin.
  10. Open a pull request in this repository with a clear title and description and link to any relevant issues
  11. Wait for a maintainer to review your pull request.

💡 Tip: yarn test failing for packages/plexis/test/index.js? Try running yarn bootstrap before running yarn test again.

Common issues and pitfalls

  • Lerna is a powerful tool, try to get through the documentation, make yourself familiar with the commands and follow the appropriate steps as described above.

  • Yarn can be a lifesaver for dependency management, try to avoid mixing npm and yarn.

  • Commitlint can be frustrating. Please use it all consciously as it provides a consistent git history.

  • If you don't know how to do something, just ask for help. We got your back!

Learning resources

Here are some learning resources, free tutorials, and books:

ES6

Jest

Lerna

plexis's People

Contributors

4doge avatar adriaanvermeire avatar angelgzs avatar bgopikrishna avatar brandon-m-skinner avatar codeclude avatar dependabot[bot] avatar drwm-base avatar dungwinux avatar eelec avatar floookay avatar green3g avatar humanolaranja avatar ihapmustapha avatar jack-chapman avatar lazav94 avatar mercyfulsin avatar nauthiz-jera avatar nikhil-vats avatar nowtryz avatar orimdominic avatar protob avatar shilangyu avatar simonsiefke avatar spaghetticodebonara avatar stsourlidakis avatar theashraf avatar vorillaz avatar yurickh 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

plexis's Issues

Feature request: `isAlphaDigit`

Checks whether the input text contains only alpha and digit characters.

Example usage

import isAlphaDigit from '@plexis/is-alphadigit';

isAlphaDigit('ABCD');
// => true

isAlphaDigit('Apollo11');
// => true

isEmpty('Hello world');
// => false

isEmpty('Hello,world');
// => false

isAlphaDigit('');
// => false

isEmpty('   ');
// => false

Aliases

import isAlphaDigit from '@plexis/is-alphadigit';
import {isAlphaDigit} from 'plexis';

Feature request: `_when`

For users consuming compose (#1) we need to provide a more flexible way for operations.
_when is used for checking and chaining within the composition for supercharged functions.

@param {Function|Boolean} [checking] A function or condition to check.
@param {Function} [func] The function to invoke.
@returns {Function} Returns the new composite function.

Example usage

import compose from '@plexis/compose';
import _when from '@plexis/when';

const inc = x => x + 1;
const add = (x, y) => x + y;
const setToZero = () => 0;


const compose = (...fns) => x => fns.reduce((r, f) => f(r), x);
const _when = (cond, f) => x => (cond(x) ? f(x) : x);

const ops = compose(inc, x => add(x, 2), _when(num => num > 0, compose(setToZero)));

ops(1); // returns 0
ops(100); // returns 0
ops(-100); // returns -97

Aliases

import _when from '@plexis/when';
import {_when} from 'plexis';

Feature request: `toLower / toFirstLower / decapitalize`

Converts the first character of the input text to lowercase. If the second parameter is true, the method converts the rest of the subject to lower case.

  @param {String} text
  @param {Boolean} isLowercase

Example usage

import toLower from '@plexis/to-lower';
toLower('foo Bar');
// => foo Bar

toLower('FOO Bar');
// => fOO Bar

toLower('fOO Bar', true);
// => foo bar

Aliases

import toLower from '@plexis/to-lower';
import {toLower, toFirstLower, decapitalize } from 'plexis';

Feature: `toEllipsis / truncate / fit`

Truncates the input text to the desired length.

Example usage

import toEllipsis from '@plexis/to-ellipsis';

toEllipsis('foo');
// => 'foo'

toEllipsis('foo', 1);
// => '...'

toEllipsis('foo', 3);
// => 'foo'

toEllipsis('As Gregor Samsa awoke one morning from uneasy dreams he found himself transformed in his bed into a monstrous vermin.', 20);
// => 'As Gregor Samsa a...'

toEllipsis('In a hole in the ground there lived a hobbit.', Infinity)
// => 'In a hole in the ground there lived a hobbit.'

toEllipsis('Last night I dreamt I went to Manderley again.', 5);
// => Last...

Aliases

import toEllipsis from '@plexis/to-ellipsis';
import {toEllipsis, truncate, fit} from 'plexis';

The packages/isUpperCase directory contains a weird extra character.

I noticed this weird usage of backslashes on the isUpperCase tests on the simple Windows 7 terminal:

 PASS  packages/toTitle/test/index.js
 PASS  packages\isUpperCase?\test\index.js
 PASS  packages/toPred/test/index.js
 PASS  packages/startsWith/test/index.js
 PASS  packages/distance/test/index.js
 PASS  packages/withoutDiacritics/test/index.js
 PASS  packages/toLower/test/index.js
 PASS  packages/compose/test/index.js
 PASS  packages/isLowerCase/test/index.js
 PASS  packages/toChicago/test/index.js
 PASS  packages/cache/test/index.js
 PASS  packages/toSucc/test/index.js
 PASS  packages/repeat/test/index.js
 PASS  packages/plexis/test/index.js
 PASS  packages/isString/test/index.js

Turns out that the directory must contain some sort of invisible character which causes this. Another way to figure this out is by attempting to enter the directory without autocomplete:

E:\dev\projects\plexis>ls -al packages\isUpperCase      <- here I just typed in "isUpperCase"
ls: cannot access 'packages\isUpperCase': No such file or directory

E:\dev\projects\plexis>ls -al packages\isUpperCase️     <- here I typed in "isUp" and pressed tab.
total 10
drwxr-xr-x 1 jc 197121   0 Oct 23 21:07 .
drwxr-xr-x 1 jc 197121   0 Oct 23 21:07 ..
drwxr-xr-x 1 jc 197121   0 Oct 23 21:07 dist
-rw-r--r-- 1 jc 197121 481 Oct 23 21:07 package.json
-rw-r--r-- 1 jc 197121 434 Oct 23 21:07 README.md
drwxr-xr-x 1 jc 197121   0 Oct 23 21:07 src
drwxr-xr-x 1 jc 197121   0 Oct 23 21:07 test

chore: Add new tip under 'Pull Requests' for `yarn test` failing for `packages/plexis/test/index.js`

Some contributors are having yarn test failures locally and on CI for packages/plexis/test/index.js and they don't know how to remedy this issue. This issue is a result of not having the various compiled files in the correct locations resulting in various modules not being found. This is remedied by running yarn bootstrap.

I propose adding a tip under the 'Pull Requests' heading:

💡 Tip: yarn test failing for packages/plexis/test/index.js? Try running yarn bootstrap before running yarn test again.

Since this is a simple tip and might not affect everyone, I think it makes sense to add this information as a tip in the README. It's proven effective already in #43 .

Feature request: `isAlpha`

Checks whether the input text contains only alpha characters.

Example usage

import isAlpha from '@plexis/is-alpha';

isAlpha('ABCD');
// => true

isAlpha('Apollo11');
// => false

isEmpty('1');
// => false

isEmpty('Hello,world');
// => false

isAlpha('');
// => false

isEmpty('   ');
// => false

Aliases

import isAlpha from '@plexis/is-alpha';
import {isAlpha} from 'plexis';

Feature : `has / includes`

Checks if the search is part of the input string in the given position.

  includes(); // => false
  includes(''); // => false
  includes('', ''); // => true
  includes('Foo', 'Foo'); // => true
  includes('Foo', 'Foo'); // => true
  includes('Foo', 'Foo', 2); // => false
  includes('Foo', 'oo');  // => true
  includes('Foo', 'Oo'); // => false

Aliases

import includes from '@plexis/includes';
import {includes, has} from 'plexis';

Feature: `padRight/ rpad` #113

Pads the input text from right to a new length.

padRight ('Foo Bar', 1); // => 'Foo Bar'
padRight ('Foo Bar', 8); // => 'Foo Bar '
padRight ('Foo Bar', 8, '*'); // => 'Foo Bar*'
padRight ('Foo Bar', 10, '*'); // => 'Foo Bar***'
padRight ('Foo Bar', 10, '123'); // => 'Foo Bar123'
padRight ('Foo Bar', 9, '123'); // => 'Foo Bar12'

Aliases

import padRight from '@plexis/pad-right';
import {padRight, rpad} from 'plexis';

Feature request: `toCamelCase / camelize `

Converts the input text to camel case.

Example usage

import toCamelCase from '@plexis/to-camel-case';

toCamelCase('Cool');
// => 'cool'

toCamelCase('cool mate');
// => 'coolMate'

toCamelCase('Hey how are you today?');
// => 'heyHowAreYouToday'

toCamelCase('PascalCase');
// => 'pascalCase'

toCamelCase('kebab-case');
// => kebabCase

Aliases

import toCamelCase from '@plexis/to-camel-case';
import {toCamelCase, camelize, camelCase} from 'plexis';

Feature request: `isUpperCase️`

Checks whether the input is a string containing only uppercase characters.

Example usage

import isUpperCase️ from '@plexis/is-uppercase';

isUpperCase️('F');
// => true

isUpperCase️('FOO');
// => true

isUpperCase️('FOO BAR.');
// => true

isUpperCase️('BAr');
// => false

Feature: `toSwapCase / swapCase`

Swaps lowercase to uppercase and vice versa for the input text.

Example usage

import toSwapCase from '@plexis/to-swap-case';

toSwapCase('Hello WORLD');
// => 'hELLO world'

toSwapCase('123 toys');
// => '123 toys'

Aliases

import toSwapCase from '@plexis/to-swap-case';
import {toSwapCase, swapCase} from 'plexis';

Feature request: `isString`

Checks whether the input is a string primitive type.

Example usage

import isString from '@plexis/is-string';
isString('Foo');
// => true

isString(1);
// => false

isString(null);
// => false

Feature request: `withoutHTML / removeHTML`

Remove HTML tags from the input text.

Example usage

import withoutHTML from '@plexis/without-html';

withoutHTML('Hello world');
// => 'Hello world'

withoutHTML('<p>Hello</p> world')
// => ' world'

withoutHTML('<p Hello world')
// => '<p Hello world'

withoutHTML('<p id="">Hello world</p>')
// => ''

withoutHTML('<p id="" Hello world</p> <b></b> from the underground ')
// => ' from the underground'

Aliases

import withoutHTML from '@plexis/without-html';
import {withoutHTML, removeHTML} from 'plexis';

Feature: `toChars/ chars`

Splits input text into an array of characters.

  toChars(); // => []
  toChars(''); // => []
  toChars(null); // => []
  toChars('Hello world'); // => [ "H", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d" ]
  toChars(1) // => ['1']
  toChars(2e5) // =>  ["2", "0", "0", "0", "0", "0"]

Aliases

import toChars from '@plexis/to-chars';
import {toChars, chars} from 'plexis';

Feature request: `compose`

Since most Plexis functions are pure we can create composed functions using closures.
compose works in a more functional way and provides users with flexibility, creating complex and tricky string operations. compose actually invokes a series of functions.

@param {Function[]} [funcs] The functions to invoke.
@returns {Function} Returns the new composite function.

Example usage

import compose from '@plexis/compose';
const inc = x => x + 1;
const add = (x, y) => x + y;
const ops = compose(inc, x => add(x, 2));

ops(1); // returns 4;
ops(10); // returns 13;

Aliases

import compose from '@plexis/compose';
import {compose, _do} from 'plexis';

Feature request: `toPascalCase / classify`

Converts the input text to pascal case.

Example usage

import toPascalCase from '@plexis/to-pascal-case';

toPascalCase('Cool');
// => 'Cool'

toPascalCase('cool mate');
// => 'CoolMate'

toPascalCase('Hey how are you today?');
// => 'HeyHowAreYouToday'

toPascalCase('camelCase');
// => 'CamelCase'

toPascalCase('kebab-case');
// => KebabCase

Aliases

import toPascalCase from '@plexis/to-pascal-case';
import {toPascalCase, classify} from 'plexis';

Feature: `padLeft / lpad`

Pads the input text from left to a new length.

padLeft ('Foo Bar', 1); // => 'Foo Bar'
padLeft ('Foo Bar', 8); // => ' Foo Bar'
padLeft ('Foo Bar', 8, '*'); // => '*Foo Bar'
padLeft ('Foo Bar', 10, '*'); // => '***Foo Bar'
padLeft ('Foo Bar', 10, '123'); // => '123Foo Bar'
padLeft ('Foo Bar', 9, '123'); // => '12Foo Bar'

Aliases

import padLeft from '@plexis/pad-left';
import {padLeft, lpad} from 'plexis';

Feature: `insert`

Inserts into the input text a string at specified position.

  insert(); // => ''
  insert('dg'); // => 'dg'
  insert('dg', o); // => 'dgo'
  insert('dg', o, 1); // => 'dog'
  insert('dg', o, 100); // => 'dgo'
  insert('dg', o, -100); // => 'dgo'
  insert('dg', o, 0); // => 'odg'

Aliases

import insert from '@plexis/insert';
import {insert} from 'plexis';

Feature request: `startsWith`

Checks whether the input text starts with the given pattern.

  @param {String} text
  @param {String|Regex} pattern
  @param {Number} startingPosition, optional

Example usage

import startsWith from '@plexis/starts-with';

startsWith('This is me', 'This is');
// => true

startsWith('This is me', 'his is', 1);
// => true

startsWith('This is me', 'is is', 2);
// => true

startsWith('This is me', 'This is', 1);
// => false

Feature request: `isNumeric`

Checks whether the input is a string representation of a numeric value.

Example usage

import isNumeric from '@plexis/is-numeric';
isNumeric('1000');
// => true

isNumeric('Infinity');
// => true

isNumeric('-100.4');
// => true

isNumeric('1E+2');
// => true

isNumeric('0xFF');
// => true

isNumeric('-');
// => false

isNumeric('one');
// => false

CircleCI

Hello i have pretty much followed the instructions given inside the README page but my pull request has faced this error message :
ci/circleci: test — Your tests failed on CircleCI
and there was no explanation for what to do to satisfy its conditions!

Feature: `compare / compareLikeHuman / naturalCompare`

For most cases, humans do not sort text as machines do.

["A friend", 'Boo', "another one"].sort()
// => ["A friend", "Boo", "another one"] 😬

Let's fix that :)

/**
 * @description Compares input text as humans do.
 * @param {String} first
 * @param {String} second
 * @returns {Integer}
 * @example
 * compare('', '') // => 0
 * compare('A', 'a') // => 1
 * compare('A', 'b') // => 1
 * compare('A woman', 'a woman') // => 1
 * compare('b', 'B') // => -1 
 * compare('C', 'b') // => -1 
 * compare('Qux20', 'Qux5') // => -1
 * compare('Qux10', 'Qux11') // => 1
 */

Aliases

import compare from '@plexis/compare';
import {compare, compareLikeHuman, naturalCompare} from 'plexis';

Feature: `toSwap / swap`

Swaps every single character with the next one in a given string.

Example usage

import toSwap from '@plexis/to-swap';

toSwap('ab');
// => 'ba'

toSwap('a b');
// => ' ab'

toSwap('abcd');
// => 'badc'

Aliases

import toSwap from '@plexis/to-swap';
import {toSwap, swap} from 'plexis';

Feature request: `isEmpty`

Checks whether the input text is empty.

Example usage

import isEmpty from '@plexis/is-empty';

isEmpty('');
// => true

isEmpty('   ');
// => true


isEmpty(' b  ');
// => false

Aliases

import isEmpty from '@plexis/is-empty';
import {isEmpty} from 'plexis';

Feature request: `toChunks / chop`

Splits the input text into an array of chunks.

  @param {String} text The input String
  @param {Integer} chunkSize The size of each chunk, default to 1

Example usage

import toChunks from '@plexis/to-chunks';

toChunks('Hello world');
// => ['H', 'e', 'l', 'l', 'o']

toChunks('   ');
// => [' ', ' ', ' ']

toChunks('1234567', 2);
// => ['12', '34', '56', '7']

toChunks('1234567', 6);
// => ['123456', '7']

Aliases

import toChunks from '@plexis/to-chunks';
import {toChunks, chop} from 'plexis';

Feature request: `toCapitals / toFirstCapital / capitalize`

Converts the first character of the input text to upper case. If the second parameter is true, the method converts the rest of the subject to lower case.

  @param {String} text
  @param {Boolean} isLowercase

Example usage

import toCapitals from '@plexis/to-capitals';
toCapitals('foo Bar');
// => Foo Bar

toCapitals('fOO Bar');
// => FOO Bar

toCapitals('fOO Bar', true);
// => Foo bar

Aliases

import toCapitals from '@plexis/to-capitals';
import {toCapitals, toFirstCapital, capitalize} from 'plexis';

Feature request: `isLowercase`

Checks whether the input is a string containing only lowercase characters.

Example usage

import isLowercase from '@plexis/is-lowercase';

isLowercase('foo');
// => true

isLowercase('foo bar');
// => true

isLowercase('foo bar');
// => true

isLowercase('Bar');
// => false

Feature request: `isDigit`

Checks whether the input text contains only digit characters.

Example usage

import isDigit from '@plexis/is-digit';

isDigit('1');
// => true

isDigit('2');
// => true

isEmpty('0xFF');
// => true

isEmpty('5e-2');
// => true

isDigit('0.5e2');
// => true

isEmpty('   ');
// => false

isEmpty('A');
// => false

isEmpty(',.');
// => false

isEmpty('Hello world!');
// => false

isEmpty('Ελληνικά');
// => false

Aliases

import isDigit from '@plexis/is-digit';
import {isDigit} from 'plexis';

Feature request: `distance`

This method calculates the Levenshtein Distance between two strings.

@param {String} [fromStr]
@param {String} [toStr]
@returns {Number} The Levenshtein distance

Example usage

import distance from '@plexis/distance';
distance('book', ''back') // => 2
distance('black', 'back') // => 1
distance('Foo', 'Bar') // => 3

Aliases

import distance from '@plexis/distance';
import {distance, calcLevenshtein, levenshtein} from 'plexis';

Feature request: `toSnakeCase / underscored `

Converts the input text to snake case.

Example usage

import toSnakeCase from '@plexis/to-snake-case';

toSnakeCase('Cool');
// => 'cool'

toSnakeCase('cool mate');
// => 'cool_mate'

toSnakeCase('Hey how are you today?');
// => 'hey_how_are_you_today'

toSnakeCase('PascalCase');
// => 'pascal_case'

toSnakeCase('kebab-case');
// => kebab_case

Aliases

import toSnakeCase from '@plexis/to-snake-case';
import {toSnakeCase, underscored} from 'plexis';

Feature: `head / popFirst`

Extracts the first length characters from the input text.

  head(); // => ''
  head('Hello'); // => 'H'
  head('Hello', 2); // => 'He'
  head('Hello', 100); // => 'Hello'

Aliases

import head from '@plexis/head';
import {head, first, popFirst} from 'plexis';

Feature request: `toKebabCase / dasherize / slugify `

Converts the input text to kebab case.

Example usage

import toKebabCase from '@plexis/to-kebab-case';

toKebabCase('Cool');
// => 'cool'

toKebabCase('cool mate');
// => 'cool-mate'

toKebabCase('Hey how are you today?');
// => 'hey-how-are-you-today'

toKebabCase('camelCase');
// => 'camel-case'

toKebabCase('PascalCase');
// => pascal-case

Aliases

import toKebabCase from '@plexis/to-kebab-case';
import {toKebabCase, dasherize, slugify} from 'plexis';

Feature request: `toPlural`

Converts the input text to its plural form.
Optional param: Count.
Optional param: Custom plural form (must also provide a count).

Example usage

import toPlural from '@plexis/to-plural';

toPlural('example');
// => 'examples';

toPlural('example', 10);
// => 'examples';

toPlural('example', 1);
// => 'example';

toPlural('example', 'examplez', 10);
// => 'examplez';

toPlural('example', 'examplez', 1);
// => 'example';

Aliases

import toPlural from '@plexis/to-plural';
import {toPlural, pluralize} from 'plexis';

Feature request: `toTurabian/ toChicagoManualStyle/ toChicagoStyle`

A method that transforms text according to Turabian / Chicago Style format.

@param {String} [txt] The text to transform
@returns {String} Returns text transformed according to the The Chicago Manual of Style.

Example usage

import toChicago from '@plexis/to-chicago';
toChicago('This is a title'); // returns 'This Is a Title'
toChicago('in Turabian shows a sample title page for a class paper.'); // returns 'In Turabian Shows a Sample Title Page for a Class Paper.'
toChicago('camelCase PascalCase snake_case and kebab-case'); // returns 'Camelcase Pascalcase Snake_case and Kebab-Case'

Aliases

import toChicago from '@plexis/to-chicago';
import {toTurabian, toChicagoManualStyle, toChicagoStyle, toChicagoTitle } from 'plexis'

Feature: `tail / rest / last / pop`

Extracts the last length characters from the input text.

  tail(); // => ''
  tail('Hello'); // => 'o'
  tail('Hello', 2); // => 'lo'
  tail('Hello', 100); // => 'Hello'

Aliases

import tail from '@plexis/tail';
import {tail, rest, last, pop} from 'plexis';

Feature: `toHuman / humanize`

Converts the input string from camelCase, PascalCase, kebab-case or snake_case to a more human-readable format.
The method also trims any whitespace and removes repeated whitespace from the input text.

Example usage

import toHuman from '@plexis/to-human';

toHuman('foo');
// => 'Foo'

toHuman('foo     bar');
// => 'Foo bar'

toHuman(' foo-bar  baz quxQuux corge_grault GarplyWaldo');
// => 'Foo bar baz qux quux corge grault garply waldo'

toHuman(' foo-bar-baz qux       quux');
// => 'Foo bar baz qux quux'

Aliases

import toHuman from '@plexis/to-human';
import {toHuman, humanize} from 'plexis';

Feature request: `withoutIndent / removeIndent / dedent`

Remove leading whitespace from each line in a string

Example usage

import withoutIndent from '@plexis/without-indent';

withoutIndent('Hello world');
// => 'Hello world'

withoutIndent('\nHello world')
// =>
//'
// Hello world'

withoutIndent('\t\t\t\tHello world')
// => 'Hello world'

withoutIndent('\t\t\t\tHello \nworld')
// => '
//				Hello 
// world'


withoutIndent('\t\t\t\tHello\tdear \nworld')
// => '				Hello	dear 
// world'

Aliases

import withoutIndent from '@plexis/without-indent';
import {withoutIndent, removeIndent, dedent} from 'plexis';

Feature: `countWords`

Returns the number of words contained in the input text.

  countWords(); // => 0
  countWords(''); // => 0
  countWords('     ') // => 0
  countWords('Hello   World') // => 2
  countWords('Hello   World    !!') // => 2

Aliases

import countWords from '@plexis/count-words';
import {countWords} from 'plexis';

Feature: `withPad / pad / lrpad`

Pads the input text to a new length.

  pad(); // => ''
  pad('Hello', 1); // => 'Hello'
  pad('Hello', 7); // => '  Hello  '
  pad('Hello', 7, '*'); // => '*Hello*'
  pad('Hello', 10, '*'); // => '**Hello***'
  pad('Hello', 10, '123'); // => '123Hello12'

Aliases

import pad from '@plexis/pad';
import {pad, lrpad} from 'plexis';

Feature request: `endsWith`

Checks whether the input text ends with the given pattern.

  @param {String} text
  @param {String|Regex} pattern
  @param {Number} startingPosition, optional

Example usage

import endsWith from '@plexis/ends-with';

const txt = 'This is me';

endsWith(txt, 'is me');
// => true

endsWith(txt, 'is m', txt.length - 1);
// => true

endsWith(txt, 'is m', txt.length);
// => false

endsWith(txt, 'Foo');
// => false

Feature request: `cache`

A caching mechanism is vital for string operations. Similar to lodash/memoize the caching mechanism can significantly improve the dev and user's experience and performance.

@param {Function} [func] The function to have its output memoized.
@param {Function} [resolver] The function to resolve the caching mechanism.
@returns {Function} Returns the new memoized function.

Example usage

import cache from '@plexis/cache';

const toLower = x => x.toLowerCase()
const toLowerCache = cache(toLower); 

// We are adding a dummy resolver function which returns the same cache every single time
const toLowerCacheWithResolver = cache(toLower, x => 'a'); 

toLowerCache('A'); // returns a;
toLowerCache('B'); // returns b;

toLowerCacheWithResolver('A'); // returns a;
toLowerCache('B'); // returns a !!;

Notes
The API should expose the caching layer per function, eg:

import cache from '@plexis/cache';

const toLower = x => x.toLowerCase()
const toLowerCache = cache(toLower); 

toLowerCache('A'); // returns a;
toLowerCache('B'); // returns b;

console.log(toLowerCache.cache) // outputs the cache object

Hint
Map works great for modern environments

Aliases

import cache from '@plexis/cache';
import {cache, memoize} from 'plexis';

Feature request: `repeat / multiply`

Repeats the input text number of times.

@param {String} [text] The input text.
@returns {Integer} times How many times shall we repeat the text, default to 1
@param {String} glue The glue for the output, default to '' 
@returns {String} The repeated string

Example usage

import repeat from '@plexis/repeat';

repeat('ABCD');
// => true

repeat('Apollo11', 2);
// => 'Apollo11Apollo11'

repeat('x', 2);
// => 'xx'

repeat('x', 2, '+');
// => 'x+x'

repeat('xx', 2, '_');
// => 'xx_xx'

Aliases

import repeat from '@plexis/repeat';
import {repeat, multiply} from 'plexis';

Starts in French, Saves English and reverts to french

Describe the bug
It would be nice to have an env variable that you can set for language so that it will start in your preferred language. I finally clicked enough of the buttons to find the settings and was able to save (i think) and it will show English for a half-second and revert to French. I am also not seeing any confirmation of connectivity from Plex, Radarr or Ollama.

To Reproduce
deploy and open the UI, hunt for the settings button and change the settings and try to figure out the save button to save with. Once the save button is clicked, there is no indication that the settings have saved. close the settings and refresh the browser page, it will show preferred language and revert.

Maybe using codesandbox or JSFiddle in order to recreate the bug ?

Expected behavior
An easy way to set preferred language and it save the settings.

Additional context
If there is a settings file somewhere in the container, it might be a good idea to allow for a mapped directory to create a persistent location so that the settings are saved outside of the container.

Feature: `count`

Return the number of characters in the input text.
An optional matcher can be passed as a validator for input characters.

  count(); // => 0
  count(''); // => 0
  count('Hello') // => 5
  count('Hello   ') // => 8
  count('Hello   ', char => char !== ' ') // => 5

Aliases

import count from '@plexis/count';
import {count} from 'plexis';

Feature request: `escapeHTML`

Takes the input text and converts HTML special characters to their entity equivalents.

Example usage

import escapeHTML from '@plexis/escapeHTML';

escapeHTML('ABCD');
// => 'ABCD'

escapeHtml('<3')
// => '&lt;3'

escapeHtml('<p>This is cool</p>')
// => '&lt;p&gt;This is cool&lt;/p&gt;'

Aliases

import escapeHTML from '@plexis/escape-html';
import {escapeHTML} from 'plexis';

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.