Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@camwiegert/typical
Advanced tools
Animated typing in ~400 bytes :blowfish: of JavaScript.
npm install @camwiegert/typical
Instead of using a package manager, you can download typical.js
from GitHub and import it locally or import it directly from a CDN like unpkg.
type(target: HTMLElement, ...steps: any[]) => Promise<void>;
The module exports a single function, type
, which takes a target element as its first argument, and any number of additional arguments as the steps to perform. Additional arguments perform actions based on their type:
string
arguments will be typednumber
arguments will pause, in millisecondsfunction
arguments will be called with the target element as an argumentPromise
arguments will wait for resolutionThe most basic usage of type
is providing a target element and a string to type.
import { type } from '@camwiegert/typical';
type(element, 'text');
In order to pause typing at any point, pass a number of milliseconds to pause.
type(element, 'Hello', 1000, 'Hello world!');
In order to loop, pass type
as a parameter to itself at the point at which you'd like to start looping. It can be helpful to alias type
as loop
to be explicit.
import {
type,
type as loop
};
const steps = [1000, 'Ready', 1000, 'Set', 1000, 'Go'];
type(element, ...steps, loop);
To loop a finite amount, pass your steps multiple times.
type(element, ...steps, ...steps, ...steps);
When passed a Promise
, type
will wait for it to resolve before continuing. Because type
itself returns a Promise
, that means you can wait on a set of steps to complete before starting another.
const init = type(target, 'In a moment...', 500);
type(target, init, 'start', 500, 'looping', loop);
Function arguments are passed the target element, and can be useful for operating on the target element between steps. If you return a Promise
, type
will wait for it to resolve.
const toggle = (element) =>
element.classList.toggle('is-typing');
type(target, toggle, 'Type me', toggle);
FAQs
Animated typing in ~400 bytes
We found that @camwiegert/typical demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.