0.18.10 • Published 3 years ago

polyfull v0.18.10

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

PolyFull

Logo

JavaScript TypeScript

EcmaScript

CI Coverage Status Known Vulnerabilities NPM version NPM downloads

:warning: THIS IS INTENDED TO USE ONLY IN FINAL APPLICATIONS.

if you use this in library, any other applications that use your library will have polyfull injected as well.
please DO NOT use this if you are building a library, use this only where you have control of your node interpreter.
also, if you are using some other polyfiller, be sure that there is no overlaps, or something will broke. Thanks!

PolyFull is a library intended to augment JavaScript capabilities. Somehow JavaScript is still missing some of the basic functionalities that are usually provided through other functions.

Its aim is to solve this issue by injecting the missing functionalities into the core components.

:new: Submit request for functionality that are missing

Some nice feature are missing in Javascript? Submit to me and i will take care of it!

:package: Installation

npm install polyfull

:rocket: Usage

simply import polyfull (once in your index.ts/js) to have access to supercharged functionality.

import 'polyfull'

:chart_with_upwards_trend: Examples

Some of functions that you might need to use.

import 'polyfull'

// ArrayConstructor
Array.zip([1, 2, 3], ['a', 'b', 'c']) // => [[1, 'a'], [2, 'b'], [3, 'c']]
Array.collapse([1], [2, 3], [4, 5, 6]) // => [1, 2, 3, 4, 5, 6]
Array.intersect([1, 2, 3], [2, 3, 4]) // => [2, 3]
Array.unique([1, 2], [2, 3], [3, 4]) // [1, 2, 3, 4]

// Array
[1, 2, 3].remove(2) // => [1, 3]
[1, 2, 3].removeIndex(2) // => [1, 2]
[1, 2, 3].first() // => 1
[1, 2, 3].last() // => 3

// DateConstructor
Date.current() // => new Date(Date.now())

// Date
new Date(0).addHours(1) // => 1970-01-01T01:00:00.000Z
new Date(0).isBefore(new Date(Date.now())) // => true
new Date(0).isAfter(new Date(Date.now())) // => false
new Date(0).diff(new Date()) // => how many ms passed from 1970? :D

// NumberConstructor
Number.random() // => -789.0123
Number.random(0) // => 789.0123
Number.random(0, 100) // => 89.0123
Number.randomInt(0) // => 42

// Number
7.0.isPrime() // => true
3.0.pow(2) // => 6
40.0.goldenRation() // => [24.72~, 15.28~]
50.0.percentage(20) // => 10

// Promise
await Promise.allProperties({
  a: Promise.resolve(1),
  b: Promise.resolve(2),
}) // => { a: 1, b: 2 }

await Promise.allPropertiesSettled({
  a: Promise.resolve(1),
  b: Promise.reject(2)
}) // => {
//   a: { status: 'fulfilled', value: 1 },
//   b: { status: 'rejected', reason: 2 }
// }

// String
'hello'.reverse() // => "olleh"
'racecar'.isPalindrome() // => true
'0x01'.isNumeric() // => true
'polyfull'.equalsIgnoreCase('POLYFULL') // => true

// And Many Many Others!!

:toolbox: Summary

:arrow_forward: ArrayConstructor

MethodDescription
isNotArraycheck if arguments is not array
zipcombine multiple array toghter by index
collapsecollapse multiple array into single array
intersectRetrive intersecate elements (elements that are in each array)
uniqueReturn an array with unique values for each array

:arrow_forward: Array

MethodDescription
firstget first element from array
lastget first element from array
insertinsert new element in specific position
removeremove element from array
removeIndexremove element from array at specified index
prependprepend an element into the array
includesEverycheck if the other Array includes every element in Array
includesAnycheck if the other Array includes any element in Array
chunksplit array in cunks of desired size
randomReturn a random element from the array
shuffleshuffle the array sorting element in random order

:arrow_forward: DateConstructor

MethodDescription
currentReturn a Date object representing Date.now()

:arrow_forward: Date

MethodDescription
addMillisecondsadd milliseconds to Date
addSecondsadd seconds to Date
addMinutesadd minutes to Date
addHoursadd hours to Date
addDateadd days to Date
addMonthadd months to Date
addFullYearadd Years to Date
subMillisecondssubtract milliseconds from Date
subSecondssubtract seconds from date
subMinutessubtract minutes from Date
subHourssubtract hours from Date
subDatesubtract days from Date
subMonthsubtract months from Date
subFullYearsubtract years from Date
isBeforecheck if current date is before another
isAftercheck if current date is after another
isSamecheck if two date are the same
diffdifference in ms between two dates

:arrow_forward: NumberConstructor

MethodDescription
randomgenerate a number between min-max (default: from Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER)
randomIntgenerate an integer between min-max (default: from Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER)

:arrow_forward: Number

MethodDescription
absReturns the absolute value of a number (the value without regard to whether it is positive or negative). For example, the absolute value of -5 is the same as the absolute value of 5.
acosReturns the arc cosine (or inverse cosine) of a number.
acoshReturns the inverse hyperbolic cosine of a number.
asinReturns the arcsine of a number.
asinhReturns the inverse hyperbolic sine of a number.
atanReturns the arctangent of a number.
atan2Returns the angle (in radians) from the X axis to a point.
atanhReturns the inverse hyperbolic tangent of a number.
cbrtReturns an implementation-dependent approximation to the cube root of number.
ceilReturns the smallest integer greater than or equal to its numeric argument.
clz32Returns the number of leading zero bits in the 32-bit binary representation of a number.
cosReturns the cosine of a number.
coshReturns the hyperbolic cosine of a number.
expReturns e (the base of natural logarithms) raised to a power.
expm1Returns the result of (e^x - 1), which is an implementation-dependent approximation to subtracting 1 from the exponential function of x (e raised to the power of x, where e is the base of the natural logarithms).
floorReturns the greatest integer less than or equal to its numeric argument.
froundReturns the nearest single precision float representation of a number.
imulReturns the result of 32-bit multiplication of two numbers.
logReturns the natural logarithm (base e) of a number.
log10Returns the base 10 logarithm of a number.
log1pReturns the natural logarithm of 1 + x.
log2Returns the base 2 logarithm of a number.
powReturns the value of a base expression taken to a specified power.
roundReturns a supplied numeric expression rounded to the nearest integer.
signReturns the sign of the x, indicating whether number is positive, negative or zero.
sinReturns the sine of a number.
sinhReturns the hyperbolic sine of a number.
sqrtReturns the square root of a number.
tanReturns the tangent of a number.
tanhReturns the hyperbolic tangent of a number.
truncReturns the integral part of the a numeric expression, x, removing any fractional digits. If x is already an integer, the result is x.
isEvenReturn true if number is even
isOddReturn true if number is odd
isPrimeReturn true if number is prime
isDivisibleByReturn true if number divisible by other
goldenRatioReturn golden long and short side ration of number
percentageReturn percentage of number
factorialReturn factorial of number

:arrow_forward: PromiseConstructor

MethodDescription
allPropertiesCreates an Object where Promise that are resolved in the same key of the passed Object, or rejected when any Promise is rejected.
allPropertiesSettledCreates an Object where Promise values that are resolved with an object of results when all of the provided Promises resolve or reject.

:arrow_forward: String

MethodDescription
reversereverse a string
toBase64convert to base64
fromBase64convert from base64
toTitleCasemake first letter of each word uppercase
ucFirstmake first letter uppercase
toKebabCasemake string in kebab case representation
isNumericcheck if string is valid numeric
isPalindromecheck if string is palindrome
equalsIgnoreCasecheck if string is equal to other ignoring case
unrepeatreplace multiple character/string repetition with single one
limitlimit the length of the string
padPads string left and right

:books: Documentation

Full Documentation

:label: License

MIT

0.18.10

3 years ago

0.18.9

3 years ago

0.11.0

3 years ago

0.11.1

3 years ago

0.13.0

3 years ago

0.11.2

3 years ago

0.15.0

3 years ago

0.15.1

3 years ago

0.17.0

3 years ago

0.9.0

3 years ago

0.18.1

3 years ago

0.18.2

3 years ago

0.18.3

3 years ago

0.18.4

3 years ago

0.18.5

3 years ago

0.18.6

3 years ago

0.18.7

3 years ago

0.18.8

3 years ago

0.10.1

3 years ago

0.12.0

3 years ago

0.10.2

3 years ago

0.12.1

3 years ago

0.10.3

3 years ago

0.14.0

3 years ago

0.12.2

3 years ago

0.10.4

3 years ago

0.14.1

3 years ago

0.10.5

3 years ago

0.16.0

3 years ago

0.10.6

3 years ago

0.16.1

3 years ago

0.10.7

3 years ago

0.18.0

3 years ago

0.10.8

3 years ago

0.10.0

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.3.0

3 years ago

0.3.6

3 years ago

0.7.1

3 years ago

0.3.5

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.5.0

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.7.0

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.9

3 years ago

0.3.13

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.4.10

3 years ago

0.4.17

3 years ago

0.4.15

3 years ago

0.4.16

3 years ago

0.4.13

3 years ago

0.4.14

3 years ago

0.4.11

3 years ago

0.4.12

3 years ago

0.4.5

3 years ago

0.8.0

3 years ago

0.4.4

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.6.1

3 years ago

0.4.3

3 years ago

0.6.0

3 years ago

0.4.2

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.8

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.3

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago