2.4.5 • Published 9 months ago

cerceis-lib v2.4.5

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

Cerceis-Library (known as CLIB).

A Quality of life library

  • Contains list of quality of life functions that is written in TypeScript and es6.
  • Module
  • Author: Cerceis

Installation

npm i cerceis-lib@latest

Usage

*Recommended

import { Generate } from "cerceis-lib";
const id = Generate.objectId();

or

const { Generate } = require("cerceis-lib");
const id = Generate.objectId();

List of functions

*Documentation written as JSDoc. Most of the IDE should recognize if you hover above the function.

**To make things more organized, functions are separated into their respective parent, simply import the parent to use them.**

Catalog still in progress!

  • Constant: database of various category.
    • gemStones: List of Gem stones name.
    • colors: List of Color's name.
  • Delay: Quick async/await wrapper for delay. ex) await Delay(100).
  • FromArray: Collection of array methods.
    • getRandom: Get random element from an array.
    • getLargest: Get largest element from an array.
    • getSmallest: Get smaller element from an array.
    • getIntersect: Get intersection of two arrays.
    • shuffle: Shuffle array.
    • thanosSnap: Randomly remove half of the element.
    • toObject: Convert array into object.
    • log: A wrapper to console log an array, can take specified index range to print specific range, useful when logging large dataset.
    • includeAll: Compare 2 arrays and return true if all elements are included in each other.
    • isEqual: Compare 2 array, strictly typed, only works with primitives elements.
  • FromNum: Collection of Number methods.
    • roll: Roll percentage. ex) roll(60), 60% will return true.
    • diceRoll: Typical TRPG dice roll. ex) FromNum.diceRoll(3).D(20) = Roll 3 D20 Dice.
    • minMaxScale: Scale number down to 0 ~ 1.
    • unminMaxScale: Revert back to original value.
    • sum: Literally Sum up a list of numbers.
    • softMax: Converts a vector of K real numbers into a probability distribution of K possible outcomes.
    • mean: Return the mean of an list of numbers.
    • toRomanNumeral: Convert numeric values into Roman Numeral string.
    • sigmoid: A sigmoid function is a bounded, differentiable, real function that is defined for all real input values and has a non-negative derivative at each point and exactly one inflection point.
    • relu: ReLU (Rectified Linear Unit function)
    • softPlus: Soft Plus function
    • toNearest: Round number to nearest specified number.
    • toShortReadable: Convert number into short readable string. Ex) 1000 -> 1k, 1,500,000 -> 1.5m
    • stdDiv: Return the standard diviation of the given list.
  • FromObject: Collection of Object methods.
    • ObjectToArray: Convert object into Array.
    • flatten: Flatten nested object.
    • getDeepest: Get deepest entries of a nexted object.
    • sumAll: Sum all the value in an object.
    • min: Find the min value in an object.
    • max: Find the max value in an object.
  • FromString: Collection of String methods.
    • copyToClipboard: Copy string to clipboard.
    • replaceFirst: Replace first N number of letter with desired string.
    • replaceLast: Replace last N number of letter with desired string.
    • parseCookies: Parse http cookies into object.
    • deepClean: Purify string, leaving only 0-9 a-z A-Z.
    • count: Count the number of occurrences of the disired word/letter.
  • FromTime: Collection of time methods.
    • jpnDayMap: Not a function. Map value of int to jpn day label
    • format: Format date object into "YYYY-MM-DD HH:mm:ss".
    • toMs: Convert time to ms.
    • toSeconds: Convert time to seconds.
    • toMinutes: Convert time to minutes.
    • toHours: Convert time to hours.
    • toDateTimeShortLocale: Convert time to short human readable date string.
  • FromVector: Vector manipulation.
    • create: Create a vector object.
      • add
      • limit
      • div
      • mult
      • heading
      • sub
      • setMag
      • magSq
      • mag
      • normalize
      • copy
      • dist
      • toVector2
      • toVector3
  • Gacha: Gacha system.
  • Generate: Collection of data generation methods.
    • alphanum: Generate Alphanumeric value.
    • objectId: Generate objectId.
    • int: Generate Integer.
    • random: Generate random number of given range.
    • array: Array of selected element type.
    • alphabate: Generate alphabate.
    • currentDate: Current date "YYYY-MM-DD".
    • currentTime: Current time "HH:mm:ss".
    • currentDateTime: Current date time "YYYY-MM-DD HH:mm:ss".
    • listOfDateOfDays: Generates and return list of date of specified day.
  • Is: Type check.
  • KMeans: Simplified K-means clustering method.
  • Logger: Coloful and advance console.log() wrapper.
  • Obfuscator: Obfuscate string.
  • Sha256: Sha256 algorithm.
  • Validator: Form validation (in-progress)

Versions:

VersionDateDescription
2.4.12023-4-7Added FromVector, multiple functions in FromArray.
2.2.32023-1-11Added FromNum.toShortReadable.
2.2.22023-1-6Added Constant.
2.2.02023-1-5Added some more functions, and mainly new "FromVector" that can do various vector manipulation.
2.1.02022-10-5Added multiple mathematical functions and fixed memory leak on Delay on some browser.
2.0.12022-8-16Major update, structure changed and added lot's of unfction.
1.5.702022-8-9Added FromObject, Moved ArrayToObject to FromArray, and ObjectToArray to FromObject.
1.5.622022-6-9Added Num
1.5.302022-3-14Added "Is", a function set to check various type.
1.5.242022-3-08Added Prob and fixed various bugs.
1.52022-2-16Added Delay & various fixes. Now supports both CJS and MJS.
1.32021-12-28Updated documentation, Added JSDoc, ShuffleArray. Merged GenerateObjectId, Array, RandomInt, Alphanum into Generate. Merged GetLargest, GetRandomElement, GetSmallest, Intersect into GetArray
1.22021-12-23Added TomeConverter, KMeans StringPadding
1.12021-12-17Added Logger, CopyToClipboard, several readme.md.

FAQ

  • There is an old version of cerceisLib, what are the difference ?
    There's one written 2 years ago, althought it still can be used, but it's not recommended. I will be gradually migrating most of the functions to this newer version.
2.4.5

9 months ago

2.4.4

9 months ago

2.4.3

11 months ago

2.4.2

1 year ago

2.4.1

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.2.3

1 year ago

2.4.0

1 year ago

2.2.2

1 year ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.1.10

1 year ago

2.2.8

1 year ago

2.1.9

1 year ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.6

1 year ago

2.1.5

2 years ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.0

2 years ago

2.0.5

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.0.1

2 years ago

1.5.62

2 years ago

1.5.50

2 years ago

1.5.51

2 years ago

1.5.61

2 years ago

1.5.30

2 years ago

1.5.40

2 years ago

1.5.20

2 years ago

1.5.14

2 years ago

1.5.13

2 years ago

1.5.12

2 years ago

1.5.11

2 years ago

1.5.10

2 years ago

1.5.9

2 years ago

1.5.8

2 years ago

1.5.7

2 years ago

1.5.6

2 years ago

1.5.5

2 years ago

1.4.5

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.81

2 years ago

1.3.80

2 years ago

1.3.79

2 years ago

1.3.78

2 years ago

1.3.77

2 years ago

1.3.76

2 years ago

1.3.75

2 years ago

1.3.74

2 years ago

1.3.73

2 years ago

1.3.72

2 years ago

1.3.71

2 years ago

1.3.70

2 years ago

1.3.69

2 years ago

1.3.68

2 years ago

1.3.67

2 years ago

1.3.66

2 years ago

1.3.65

2 years ago

1.3.64

2 years ago

1.3.63

2 years ago

1.3.62

2 years ago

1.3.61

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago