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

frame-scheduling

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frame-scheduling - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

lib/src/frameScheduling.d.ts

2

package.json
{
"name": "frame-scheduling",
"version": "0.4.1",
"version": "0.5.0",
"description": "Asynchronous start of functions in JS. Supports priority and interrupt execution every 16 milliseconds, to achieve 60fps.",

@@ -5,0 +5,0 @@ "main": "lib/frameScheduling.js",

const context = typeof window !== "undefined" ? window : global;
let defer: Function;
let defer: (f: () => void) => void;
if ("requestAnimationFrame" in context) {
defer = requestAnimationFrame.bind(context);
} else if ("setImmediate" in context) {
defer = setImmediate.bind(context);
} else {

@@ -18,5 +20,5 @@ defer = setTimeout.bind(context);

interface listNode {
value: Function;
next: listNode | null;
interface IListNode {
value: () => void;
next: IListNode | null;
}

@@ -26,4 +28,4 @@

private length: number;
private head: listNode | null;
private last: listNode;
private head: IListNode | null;
private last: IListNode;

@@ -35,6 +37,6 @@ constructor() {

push(value: Function) {
const node: listNode = {
value: value,
next: null
public push(value: () => void) {
const node: IListNode = {
next: null,
value,
};

@@ -53,4 +55,4 @@

shift() {
const currentHead = <listNode>this.head;
public shift() {
const currentHead = this.head as IListNode;
const value = currentHead.value;

@@ -64,3 +66,3 @@

isEmpty() {
public isEmpty() {
return this.length === 0;

@@ -77,6 +79,6 @@ }

const sortJobsByNumber = (jobs: Object) => {
const sortJobsByNumber = (jobs: object) => {
if (!jobsSortActual) {
jobsSortCached = Object.keys(jobs).sort(
(left: string, right: string) => Number(left) - Number(right)
(left: string, right: string) => Number(left) - Number(right),
);

@@ -97,3 +99,3 @@ jobsSortActual = true;

const addJob = (callback: Function, priority: number) => {
const addJob = (callback: () => void, priority: number) => {
if (!listJobs[priority]) {

@@ -109,3 +111,3 @@ listJobs[priority] = new LinkedList();

for (var i = keys.length; i > 0; i--) {
for (let i = keys.length; i > 0; i--) {
const key = keys[i - 1];

@@ -139,3 +141,3 @@

} catch (e) {
console.error(e);
console.error(e); // tslint:disable-line
}

@@ -160,3 +162,3 @@

return function scheduling(callback: Function, { priority = P_NORMAL } = {}) {
return function scheduling(callback: () => void, { priority = P_NORMAL } = {}) {
addJob(callback, priority);

@@ -163,0 +165,0 @@

@@ -19,3 +19,3 @@ {

},
"include": ["src/**/*", "test/**/*"]
"include": ["src/**/*", "tests/**/*"]
}
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