1.0.2-beta-1 • Published 2 years ago

penaui-helpers v1.0.2-beta-1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

penaui-helpers-js

A list of helpers function to support unpad ecosystem javascript

Install

npm install --save penaui-helpers-js

Usage

import React, { Component } from "react";
import { truncateText } from "penaui-helpers-js";

class Example extends Component {
  render() {
    const bodyText =
      "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting.";

    return <div>{truncateText(bodyText, 20)}</div>;
    // This will return "Lorem Ipsum is simpl..."
  }
}

export default Example;

String Helpers

FunctionDescriptionExampleArgs
truncateTextReturns truncated text ending with "..."truncateText(string, 20)1. string 2. length
toTitleCaseReturns string in title casetoTitleCase(string)1. string

Number Helpers

FunctionDescriptionExampleArgs
intCommaReturns number in comma seperated numberintComma(number)1. number
isEvenReturns if number is even or notisEven(number)1. number

Array Helpers

Object Helpers

FunctionDescriptionExampleArgs
copyObjectReturns a copy of the objectcopyObject(obj)1. object

URL Helpers

FunctionDescriptionExampleArgs
addParamAdds parameter to url, EG: www.google.com/?page=1addParam('page', 1)1. option, 2. option
updateParamUpdates parameter to url, EG: www.google.com/?page=1 => ?page=2addParam('page', 2)1. option, 2. option

License

MIT © forked from dane-brown