New npm package that may help you with JavaScript

Welcome dev community!

Today I would like to introduce you to my npm package, which can be useful for any beginner or advanced JavaScript developer.

It's a collection of functions inspired from Python and rewritten for JavaScript, so now you can easily e.g. capitalize a string or display e.g. last 4 characters from a string.

To check it out, just install it quickly and easily via npm

$ npm install simhok
# or
$ yarn add simhok

Now all we have to do is import the package into JS project

// Import what you need
import { len, log } from "simhok"

// Import all functions
import * as Sim from "simhok"

// In node.js
const { len, log } = require("simhok");

Available functions

const user = "sebastian";
const users = ["sebastian", "klaudia"];
const hello = "hello world";

len(user);             // number:9
len(users);            // number: 2
capitalize(hello);     // string: Hello world
capitalizeAll(hello);  // string: Hello World
upper(user);           // string: SEBASTIAN
lower(user);           // string: sebastian

startsWith(user, "s"); // boolean: true
startsWith(user, "S"); // boolean: false
endsWith(user, "n");   // boolean: true

rstrip(user, "an");    // string: sebasti
lstrip(user, "s");     // string: ebastian

split(user, [0]);      // string: s
split(user, [0, 2]);   // string: se
split(user, [3, 0]);   // string: astian
split(user, [0, -3]);  // string: ian

let james_bond = 7;
zfill(james_bond, 2);  // string: 007

count([1,2,1,3,1], 1); // number: 3
compareIgnoreCase("Sebastian", "sebastian"); // boolean: true

abs(42);              // number: -42
abs(-42);             // number: 42

n("1_000_000")        // number: 1000000

log("This is pretty awesome 🎉"); // "This is pretty awesome 🎉"

Example in React

import { len, upper } from "simhok"; 

const App = () => {
  let name = upper("Sebastian");
  let users = len(["Sebastian", "Klaudia"]);

  return <div>{users > 0 && name}</div>;
};
import * as Sim from "simhok"; 

const App = () => {
  let name = Sim.upper("Sebastian");
  let users = Sim.len(["Sebastian", "Klaudia"]);

  return <div>{users > 0 && name}</div>;
};

GitHub logo skorotkiewicz / SimHok

A lightweight and easy-to-use library for features you probably use every day

I invite you to test and write a few opinions what you think about the package.
I will gladly accept PR!

Post edited at: 16/06/2021

18