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

evidently-tweens

v1.0.0

Published

TypeScript powered tweening library made with gamedev and clean code in mind.

Downloads

3

Readme

Evidently Tweens

Build Status

A simple tweening library powered by TypeScript made for game dev for those who like their code to be type-safe and explicit in what it does.

Getting Started

This library was written in TypeScript but will also work in projects written in JavaScript.

Installing

Add it to your project via:

npm i --save evidently-tweens

Documentation

The full documentation can be found here.

An example of using tweens:

import {TweenParallel} from "./TweenParallel";
import {TweenAnimate} from "./TweenAnimate";
import {TweenSequence} from "./TweenSequence";
import {TweenCallback} from "./TweenCallback";
import {TweenSleep} from "./TweenSleep";

const tween = new TweenParallel(
	() => console.log("Finished!"),
	new TweenAnimate(500, 0, 100, i => console.log(i)),
	new TweenSequence(
		undefined,
		new TweenCallback(() => console.log("Started!")),
		new TweenSleep(130),
		new TweenCallback(() => console.log("Yawn :3"))
	)
);

while (!tween.isFinished) {
	tween.advance(50);
}

Which will produce the following output in the console:

10
Started!
20
30
Yawn :3
40
50
60
70
80
90
100
Finished!

Details

  • The tweens operate on a unit-less duration, so you're free to use actual time or frames.
  • There is no global, automatic runner, you need to call advance() on a tween instance to run it for specific amount of time.
  • Every tween accepts a callback that's called when it finishes.
  • advance() method accepts the duration for which the tweens should run and returns the amount of time consumed by that tween. For example, given a sleep tween with duration=50, if you call advance(60) on it, it will return 10, because the 50 units of duration were used to run the tween.
  • The implemented tweens are:
    • TweenSleep which does nothing for the requested amount of duration (useful in TweenSequence or with a finished callback)
    • TweenCallback which instantly calls a function (useful in TweenSequence) and takes 0 duration.
    • TweenAwait which every time it runs calls a function, and if the function returns true it finishes. Takes 0 duration when it passes or all the available duration when it doesn't.
    • TweenAnimate animates a number with optional easing from certain value to another.
    • TweenParallel runs multiple tweens at the same time. On each run, advance() will return the amount of duration consumed by the longest tween in it, or 0 if there were no tweens to run.
    • TweenSequence runs tweens one after another. Any duration left from the execution of one tween will immediately be used on the next one. Thus, a single sequence with five TweenCallbacks in it will run all of them in the sigle call to advance()

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Links