Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kompanion/utils

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kompanion/utils - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

5

package.json
{
"name": "@kompanion/utils",
"version": "0.0.1",
"version": "0.0.2",
"main": "lib/index.js",

@@ -9,3 +9,4 @@ "scripts": {

"build": "rimraf ./lib && tsc",
"prepare": "yarn format && yarn lint && yarn build"
"prepare": "yarn format && yarn lint && yarn build",
"deploy": "npm publish --access public"
},

@@ -12,0 +13,0 @@ "keywords": [

46

README.md

@@ -0,3 +1,47 @@

# Kompanion utils
Tiny snippets of useful javascript code for websites and apps.
```shell
npm i @kompanion/utils
# or
yarn add @kompanion/utils
```
## Utilities
As `@kompanion/utils` is written in Typescript, you get automatic intellisense by default if using editors like VS Code.
### Arrays
#### shuffleArray
Self explanatory. The **only argument** is an `array`:
```js
import { shuffleArray } from '@kompanion/utils';
const emojis = ['😄', '🤨', '🧡', '😝'];
const randomEmoji = shuffleArray(emojis)[0];
```
### DOM-related
#### scrollToId
**Single argument:** `id: string`
Uses the [`scrollIntoView` API](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) to smoothly scroll the screen to the object defined by the given `id`. If no object is found, does nothing.
```html
<button onClick="scrollToId('contact')">Get in contact</button>
```
#### getWindowSize
Checks if there's a window object (if it's a browser) and returns an object: `{width: num, height: num}`
## TODO
- Add another `tsconfig` for an ES5 bundle
- Add another `tsconfig` for an ES5 bundle
- Finish documentation
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc