npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@splidejs/utils

v1.2.0

Published

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

Downloads

36

Readme

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.