# some-javascript-utils

> some functions for javascript

Latest version **0.10.10** (published 2025-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install some-javascript-utils
pnpm add some-javascript-utils
yarn add some-javascript-utils
bun add some-javascript-utils
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.10 |
| Published | 2025-08-11 |
| First published | 2022-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | SitoNumbis |
| Maintainers | sito8943 |
| Keywords | javascript, functions, arrays, objects, extra |

## Links

- npm: https://www.npmjs.com/package/some-javascript-utils
- Repository: https://github.com/SitoNumbis/some-javascript-utils
- Homepage: https://github.com/SitoNumbis/some-javascript-utils#readme
- Issues: https://github.com/SitoNumbis/some-javascript-utils/issues
- npm.io page: https://npm.io/package/some-javascript-utils

## Recent versions

- 0.10.10 (latest) — 2025-08-11
- 0.10.9 — 2025-08-11
- 0.10.8 — 2025-08-11
- 0.10.7 — 2025-08-11
- 0.10.6 — 2025-01-11
- 0.10.5 — 2024-12-28
- 1.0.1 — 2024-09-14
- 1.0.0 — 2024-09-14
- 0.10.4 — 2024-06-03
- 0.10.3 — 2023-11-05
- 0.10.1 — 2023-11-05
- 0.9.6 — 2023-08-28
- 0.9.5 — 2023-08-27
- 0.9.4 — 2023-08-26
- 0.9.3 — 2023-07-11
- … 12 more at https://npm.io/package/some-javascript-utils/versions

## README

# some-javascript-utils

Some functions to work better with arrays, objects and more!!

# Functions

## Arrays

### sortBy

# sortBy

How to import it?

```
import { array } from "some-javascript-utils";
// import { sortBy } from "some-javascript-utils/array";
```

or

```
const { array } from "some-javascript-utils";
// const { sortBy } = require("some-javascript-utils/array");
```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work with array of objects_

```
// ... imports

const array = [{ id: 5 }, { id: 2 }, { id: 3 }, { id: 6 }];

array.sortBy(array, "id", "asc") ;
// attribute "id" and "asc" are by default

// result
// [ { id: 2 }, { id: 3 }, { id: 5 }, { id: 6 } ]
```

## Browser

# getUserLanguage

How to import it?

```
import { browser } from "some-javascript-utils";
// import { getUserLanguage } from "some-javascript-utils/browser";
```

or

```
const { browser } = "some-javascript-utils";
// const { getUserLanguage } = "some-javascript-utils/browser";
```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work in browsers_

```
// ... imports

const userLang = getUserLanguage();
// if pass a string parameter will save the language to a cookie ()
// example: "en"

```

# parseQueries

How to import it?

```

import { browser } from "some-javascript-utils";
// import { parseQueries } from "some-javascript-utils/browser";

```

or

```

const { browser } = "some-javascript-utils";
// const { parseQueries } = "some-javascript-utils/browser";

```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work in browsers_

```

// ...imports

//! using location from useLocation() hook from "react-router-dom"

useEffect(() => {
    const { search } = location // ex: [some-url]?id=1&folder=sito
    const queryParams = parseQueries(search)
    // queryParams will value { id: "1", folder: "sito" }
},[location])


```

# scrollTo

How to import it?

```

import { browser } from "some-javascript-utils";
// import { scrollTo } from "some-javascript-utils"/browser;

```

or

```

const { browser } = "some-javascript-utils";
// const { scrollTo } = "some-javascript-utils/browser";

```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work in browsers_

```

// ... imports

// it's obviously how it works
scrollTo(0) // go to top of the page

```

# createCookie

How to import it?

```

import { browser } from "some-javascript-utils";
// import { createCookie } from "some-javascript-utils/browser";

```

or

```

const { browser } = "some-javascript-utils";
// const { createCookie } = "some-javascript-utils/browser";

```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work in browsers_

```

// ...imports

const name = "user";
const value = "sito";
const expiration = 765 // count of days or "2019-12-31 23:59:59"
createCookie(name, expiration, value);

// result
// a new cookie in document.cookie = `${name}=${value};${expires}";path=/`;

```

# getCookie

How to import it?

```

import { browser } from "some-javascript-utils";
// import { getCookie } from "some-javascript-utils/browser";

```

or

```

const { browser } = "some-javascript-utils";
// const { getCookie } = "some-javascript-utils/browser";

```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work in browsers_

```

// ...imports

const name = "user";
getCookie(name);

// result
// sito (of previous example)

```

# deleteCookie

How to import it?

```

import { browser } from "some-javascript-utils";
// import { deleteCookie } from "some-javascript-utils/browser";

```

or

```

const { browser } = "some-javascript-utils";
// const { deleteCookie } = "some-javascript-utils/browser";

```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work in browsers_

```

// ...imports

const name = "user";
deleteCookie(name);

// result
// (document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`);/

```

# validation

_To validates a storage key_

How to import it?

```

import { browser } from "some-javascript-utils";
// import { validation } from "some-javascript-utils/browser";

```

or

```

const { browser } = "some-javascript-utils";
// const { validation } = "some-javascript-utils/browser";

```

#### In Action!

🔶⚠Very important⚠🔶!!

_just work in browsers_

```

// ...imports

localStorage.setItem("user", "yo");
validation("user", "local");

// result
// true


```

# toSlug

_To turn a string to url slug_

How to import it?

```

import { toSlug } from "some-javascript-utils";


```

or

```

const { toSlug } = "some-javascript-utils";


```

#### In Action!


```

// ...imports

const urlName = toSlug("The Man on the Hills")

// urlName = the-man-on-the-hills


```

---
_Source: https://npm.io/package/some-javascript-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
