Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skorotkiewicz/simhok
A lightweight and easy-to-use library for features you probably use every day
https://github.com/skorotkiewicz/simhok
helper javascript typescript utils
Last synced: about 1 month ago
JSON representation
A lightweight and easy-to-use library for features you probably use every day
- Host: GitHub
- URL: https://github.com/skorotkiewicz/simhok
- Owner: skorotkiewicz
- Created: 2021-07-11T18:45:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-25T12:01:16.000Z (over 3 years ago)
- Last Synced: 2024-11-19T02:48:34.287Z (about 2 months ago)
- Topics: helper, javascript, typescript, utils
- Language: TypeScript
- Homepage: https://skorotkiewicz.github.io/SimHok/
- Size: 745 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SimHok
![licence badge](https://img.shields.io/npm/l/simhok?style=flat)
![last commit badge](https://img.shields.io/github/last-commit/skorotkiewicz/SimHok/main?style=flat)
![downloads badge](https://img.shields.io/npm/dm/simhok?style=flat)
![npm version badge](https://img.shields.io/npm/v/simhok?style=flat)
![size badge](https://img.shields.io/bundlephobia/min/simhok?style=flat)A lightweight and easy-to-use library for features you probably use every day.
Check the [documentation](https://skorotkiewicz.github.io/SimHok/) to see all available functions.
## Install
```sh
$ npm install simhok
// or
$ yarn add simhok
```## Import
```javascript
// 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
```javascript
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: sebastianstartsWith(user, "s"); // boolean: true
startsWith(user, "S"); // boolean: false
endsWith(user, "n"); // boolean: truerstrip(user, "an"); // string: sebasti
lstrip(user, "s"); // string: ebastiansplit(user, [0]); // string: s
split(user, [0, 2]); // string: se
split(user, [3, 0]); // string: astian
split(user, [0, -3]); // string: ian// start from 4 character and get 3 next characters
mid("Roland Watson", 4, 3) // string: andlet james_bond = 7;
zfill(james_bond, 2); // string: 007count([1,2,1,3,1], 1); // number: 3
compareIgnoreCase("Sebastian", "sebastian"); // boolean: trueflip(42); // number: -42
flip(-42); // number: 42n("1_000_000") // number: 1000000
rand(1, 100) // number: 42rept(1, 10) // number: 1111111111
rept("1", 10) // string: 1111111111clean("This is inline String !"); // string: "This is inline String!"
// or with multi lines:
clean(`Is this now ,
multi line String ? `, true);
// string:
`Is this now,
multi line String?`;log("This is pretty awesome 🎉"); // "This is pretty awesome 🎉"
```# Example in React
```javascript
import { len, upper } from "simhok";const App = () => {
let name = upper("Sebastian");
let users = len(["Sebastian", "Klaudia"]);return
{users > 0 && name};
};
``````javascript
import * as Sim from "simhok";const App = () => {
let name = Sim.upper("Sebastian");
let users = Sim.len(["Sebastian", "Klaudia"]);return
{users > 0 && name};
};
```