atzuki_dollar
v1.0.23
Published
Personal JavaScript utility library
Downloads
5
Readme
Atzuki Dollar
Atzuki dollar is personal Javascript library for both, the browser and the server. The main purpose of this library is to provide a simple, easy and fast way to use day to day Javascript functions.
Installation
NPM
npm i atzuki_dollar
CDN
<script src="https://cdn.jsdelivr.net/npm/atzuki_dollar/javascript/index.min.js"></script>
Initialization
const $ = require('atzuki_dollar');
Use
$.loop(10, (i) => {
console.log(i);// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
});
$.flatten([1, 2, 3, [4, 5, 6]]); // [1, 2, 3, 4, 5, 6]
$.randBool(); // true
Functions
- camelCase
- divisors
- each
- el
- factorial
- fibonacci
- flatten
- greatestCommonDivisor
- id
- isDivisibleBy
- isEqual
- isEven
- isOdd
- isPalindrome
- isPrime
- kebabCase
- leastCommonMultiple
- log
- loop
- lowerCase
- max
- min
- pascalCase
- pow
- randBool
- randFloat
- randInt
- randPassword
- randString
- replaceAll
- reverse
- sentenceCase
- shuffle
- snakeCase
- sort
- sortByKey
- sortByValue
- text
- titleCase
- type
- upperCase
Functions
camelCase
▸ camelCase(string
): string
Transform string to camelCase.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:226
divisors
▸ divisors(n
): number
[]
Returns all divisors of a number.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
Returns
number
[]
Defined in
index.ts:68
each
▸ each(array
, cb
): void
Loop for each element.
Parameters
| Name | Type |
| :------ | :------ |
| array
| any
[] |
| cb
| (element
: any
, index?
: number
) => void
|
Returns
void
Defined in
index.ts:211
el
▸ el(name
): HTMLElement
| null
document.querySelector wrapper
Parameters
| Name | Type |
| :------ | :------ |
| name
| string
|
Returns
HTMLElement
| null
Defined in
index.ts:323
factorial
▸ factorial(n
): number
Return the factorial of the given number.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
Returns
number
Defined in
index.ts:88
fibonacci
▸ fibonacci(n
): number
Return the fibonacci number of the given index.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
Returns
number
Defined in
index.ts:95
flatten
▸ flatten(obj
): any
Flatten the given array or object.
Parameters
| Name | Type |
| :------ | :------ |
| obj
| any
|
Returns
any
Defined in
index.ts:154
greatestCommonDivisor
▸ greatestCommonDivisor(a
, b
): number
Find the greatest common divisor of two numbers.
Parameters
| Name | Type |
| :------ | :------ |
| a
| number
|
| b
| number
|
Returns
number
Defined in
index.ts:32
id
▸ id(id
): HTMLElement
| null
document.getElementById wrapper
Parameters
| Name | Type |
| :------ | :------ |
| id
| string
|
Returns
HTMLElement
| null
Defined in
index.ts:316
isDivisibleBy
▸ isDivisibleBy(n
, by
): boolean
Check if given numbers is divisible by another number.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
| by
| number
|
Returns
boolean
Defined in
index.ts:102
isEqual
▸ isEqual(a
, b
): boolean
Check if numbers are equal.
Parameters
| Name | Type |
| :------ | :------ |
| a
| number
|
| b
| number
|
Returns
boolean
Defined in
index.ts:16
isEven
▸ isEven(n
): boolean
Check if Numbers is even.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
Returns
boolean
Defined in
index.ts:54
isOdd
▸ isOdd(n
): boolean
Check if Numbers is odd.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
Returns
boolean
Defined in
index.ts:61
isPalindrome
▸ isPalindrome(n
): boolean
Check if Numbers is palindrome.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
Returns
boolean
Defined in
index.ts:47
isPrime
▸ isPrime(n
): boolean
Check if number is prime.
Parameters
| Name | Type |
| :------ | :------ |
| n
| number
|
Returns
boolean
Defined in
index.ts:23
kebabCase
▸ kebabCase(string
): string
Transform string to kebab-case.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:235
leastCommonMultiple
▸ leastCommonMultiple(a
, b
): number
Find the least common multiple of two numbers.
Parameters
| Name | Type |
| :------ | :------ |
| a
| number
|
| b
| number
|
Returns
number
Defined in
index.ts:40
log
▸ log(...args
): void
Console.log() shortcut. Each argument will be separated by a space.
Parameters
| Name | Type |
| :------ | :------ |
| ...args
| any
[] |
Returns
void
Defined in
index.ts:303
loop
▸ loop<T
>(amount
, cb
): void
Create a for loop.
Type parameters
| Name |
| :------ |
| T
|
Parameters
| Name | Type |
| :------ | :------ |
| amount
| number
|
| cb
| (i
: number
) => T
|
Returns
void
Defined in
index.ts:294
lowerCase
▸ lowerCase(string
): string
Transform string to lower case.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:281
max
▸ max(...args
): number
Get the greater of values.
Parameters
| Name | Type |
| :------ | :------ |
| ...args
| number
[] |
Returns
number
Defined in
index.ts:4
min
▸ min(...args
): number
Get the lesser of values.
Parameters
| Name | Type |
| :------ | :------ |
| ...args
| number
[] |
Returns
number
Defined in
index.ts:10
pascalCase
▸ pascalCase(string
): string
Transform string to PascalCase.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:249
pow
▸ pow(base
, exponent
): number
Return a number representing the given base taken to the power of the given exponent.
Parameters
| Name | Type |
| :------ | :------ |
| base
| number
|
| exponent
| number
|
Returns
number
Defined in
index.ts:81
randBool
▸ randBool(): boolean
Get random boolean, true or false
Returns
boolean
Defined in
index.ts:124
randFloat
▸ randFloat(min
, max
): number
Generate a random floating point number between the given interval.
Parameters
| Name | Type |
| :------ | :------ |
| min
| number
|
| max
| number
|
Returns
number
Defined in
index.ts:108
randInt
▸ randInt(min
, max?
): number
Generate a random number between min and max
Parameters
| Name | Type |
| :------ | :------ |
| min
| number
|
| max?
| number
|
Returns
number
Defined in
index.ts:117
randPassword
▸ randPassword(length?
): string
Generate random password
Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| length
| number
| 10
|
Returns
string
Defined in
index.ts:131
randString
▸ randString(length?
): string
Generate random string
Parameters
| Name | Type | Default value |
| :------ | :------ | :------ |
| length
| number
| 10
|
Returns
string
Defined in
index.ts:143
replaceAll
▸ replaceAll(string
, search
, replace
): string
Replace all occurrences of a string.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
| search
| string
|
| replace
| string
|
Returns
string
Defined in
index.ts:219
reverse
▸ reverse(string
): string
Reverse string.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:288
sentenceCase
▸ sentenceCase(string
): string
Transform string to sentence case.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:258
shuffle
▸ shuffle<T
>(array
): T
[]
Shuffle the given array.
Type parameters
| Name |
| :------ |
| T
|
Parameters
| Name | Type |
| :------ | :------ |
| array
| T
[] |
Returns
T
[]
Defined in
index.ts:200
snakeCase
▸ snakeCase(string
): string
Transform string to snake_case.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:242
sort
▸ sort(obj
): number
[] | string
[]
Sort given array.
Parameters
| Name | Type |
| :------ | :------ |
| obj
| number
[] | string
[] |
Returns
number
[] | string
[]
Defined in
index.ts:169
sortByKey
▸ sortByKey<T
>(object
): T
Sort given object by their keys.
Type parameters
| Name |
| :------ |
| T
|
Parameters
| Name | Type |
| :------ | :------ |
| object
| T
|
Returns
T
Defined in
index.ts:185
sortByValue
▸ sortByValue(object
): any
Sort given object by their values.
Parameters
| Name | Type |
| :------ | :------ |
| object
| any
|
Returns
any
Defined in
index.ts:192
text
▸ text(el
): string
InnerText of the given element
Parameters
| Name | Type |
| :------ | :------ |
| el
| HTMLElement
|
Returns
string
Defined in
index.ts:330
titleCase
▸ titleCase(string
): string
Transform string to Title case.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:265
type
▸ type(value
): string
Return type of the given value.
Parameters
| Name | Type |
| :------ | :------ |
| value
| any
|
Returns
string
Defined in
index.ts:310
upperCase
▸ upperCase(string
): string
Transform string to upper case.
Parameters
| Name | Type |
| :------ | :------ |
| string
| string
|
Returns
string
Defined in
index.ts:274