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

@splidejs/utils

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@splidejs/utils

The collection of utility functions and constructors to share with Splide packages. This is **internal use only**.

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Splide Utils

The collection of utility functions and constructors to share with Splide packages. This is internal use only.

Quick Reference

EventBinder()

The constructor function to provide methods to subscribe native events.

EventBus()

Provides the simple event system. Note that M - type for an event map - must have index signature, but that makes all callback function AnyFunction. To avoid this:

  • Use a type alias instead of interface.
  • Or do like EventBus<EventMap & Record<string, AnyFunction>, keyof EventMap>.
EventInterface()

The constructor function that provides interface for both internal and native events. Only the root EventInterface instance can destroy all locked instances.

RequestInterval()

Requests interval like the native setInterval() with using requestAnimationFrame.

State()

The function providing a super simple state system.

Throttle()

Returns the throttled function.

abs()

Returns the absolute value of a number (the value without regard to whether it is positive or negative). For example, the absolute value of -5 is the same as the absolute value of 5.

abstractMethod()

Always throws an error.

addClass()

Adds classes to the element.

append()

Appends children to the parent element.

apply()

Create a function where provided arguments are bound. this parameter will be always null.

approximatelyEqual()

Checks if the provided 2 numbers are approximately equal or not.

assert()

Throws an error when assertion is falsy.

assign()

The alias of Object.assign() with strict type annotation.

before()

Inserts a node or nodes before the specified reference node.

between()

Checks if the subject number is between x and y.

buildAttrs()

Converts attributes provided as an object to a single string. If boolean is provided, this method treats the attribute as a boolean type. Use 'true' or 'false' (string) when you need to set it as a value.

camelToKebab()

Converts the provided string in the camel case to the kebab case.

ceil()

Returns the smallest integer greater than or equal to its numeric argument.

child()

Returns a child element that matches the specified tag or class name.

children()

Finds children that have the specified tag or class name.

clamp()

Clamps a number.

classNames()

Conditionally joins provided class names.

closest()

Starts from the provided element, searches for the first element that matches the selector in ascendants.

create()

Creates a HTML element.

display()

Sets the display CSS value to the element.

div()

Builds a div tag with classes or attributes. This is a special version of tag().

empty()

Empties the array.

error()

The alias of console.error.

find()

The find method for an array or array-like object.

floor()

Returns the greatest integer less than or equal to its numeric argument.

focus()

Focuses the provided element without scrolling the ascendant element. If providing null or an element which is not an instance of HTMLElement, this function will do nothing.

forEach()

The extended Array#forEach method that accepts a single value as an argument.

forOwn()

Iterates over the provided object by own enumerable keys with calling the iteratee function.

format()

Replaces %s in the provided string with replacements.

getAttribute()

Returns the specified attribute value.

hasClass()

Checks if the element contains the specified class or not.

includes()

Checks if the array-like object includes the value or not.

inherit()

Loosely inherits a parent component. This does not share prototype.

isArray()

Checks if the given subject is an array or not.

isBoolean()

Checks if the given subject is boolean or not.

isFunction()

Checks if the given subject is a function or not.

isHTMLElement()

Checks if the given subject is an HTMLElement instance or not. This method takes into account which window the node belongs to. Note that ownerDocument can be null and the non-null assertion looks inappropriate, but try-catch will catch the error (this makes the bundle size smaller a bit).

isNull()

Checks if the given subject is null or not.

isObject()

Checks if the given subject is an object or not.

isString()

Checks if the given subject is a string or not.

isUndefined()

Checks if the given subject is undefined or not.

matches()

Checks if the element can be selected by the provided selector or not.

max()

Returns the larger of a set of supplied numeric expressions.

measure()

Attempts to convert the provided value to pixel as the relative value to the parent element.

merge()

Recursively merges source properties to the object. Be aware that this method does not merge arrays. They are just duplicated by slice().

min()

Returns the smaller of a set of supplied numeric expressions.

nextTick()

Invokes the callback on the next tick.

noop()

No operation.

omit()

Deletes specified own keys from the object.

ownKeys()

An alias of Object.keys()

pad()

Pads the number with 0.

parseHtml()

Parses the provided HTML string and returns the first element.

parseOption()

Parses an option that may have an object literal for nested options. If users do not provided the option, this method treats it as true.

  • true or undefined: {}
  • false or null: false
  • T : T
prevent()

Call the preventDefault() of the provided event.

push()

Extended Array#push() that accepts an item or an array with items.

query()

Returns an element that matches the provided selector.

queryAll()

Returns elements that match the provided selector.

raf()

The arias of window.requestAnimationFrame().

rect()

Returns a DOMRect object of the provided element.

removeAttribute()

Removes attributes from the element.

removeClass()

Removes classes from the element.

removeNode()

Removes the provided node from its parent.

setAttribute()

Sets attribute/attributes to the element or elements. If the value is null, undefined or an empty string, the attribute will be removed.

sign()

Returns the sign of the x, indicating whether x is positive, negative or zero.

slice()

The slice method for an array-like object.

style()

Applies inline styles to the provided element by an object literal.

tag()

Builds a tag with classes or attributes.

timeOf()

Extracts the timestamp from the event object.

toArray()

Push the provided value to an array if the value is not an array.

toggleClass()

Toggles the provided class or classes by following the add boolean.

uniqueId()

Returns a sequential unique ID as "prefix-number".

unit()

Appends px to the provided number. If the value is already string, just returns it.

FAQs

Package last updated on 18 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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