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

@essentials/request-timeout

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@essentials/request-timeout - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

dist/cjs/index.d.ts

55

dist/cjs/index.js

@@ -14,25 +14,42 @@ 'use strict'

function _getRequireWildcardCache() {
if (typeof WeakMap !== 'function') return null
var cache = new WeakMap()
_getRequireWildcardCache = function() {
return cache
}
return cache
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj
} else {
var newObj = {}
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc =
Object.defineProperty && Object.getOwnPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: {}
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc)
} else {
newObj[key] = obj[key]
}
}
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return {default: obj}
}
var cache = _getRequireWildcardCache()
if (cache && cache.has(obj)) {
return cache.get(obj)
}
var newObj = {}
var hasPropertyDescriptor =
Object.defineProperty && Object.getOwnPropertyDescriptor
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc)
} else {
newObj[key] = obj[key]
}
}
newObj.default = obj
return newObj
}
newObj.default = obj
if (cache) {
cache.set(obj, newObj)
}
return newObj
}

@@ -51,3 +68,3 @@

const requestTimeout = (fn, delay) => {
let start = (0, _performanceNow.default)(),
const start = (0, _performanceNow.default)(),
handle = {}

@@ -57,3 +74,3 @@

;(0, _performanceNow.default)() - start >= delay
? fn.call()
? fn.call(null)
: (handle.value = (0, _raf.default)(loop))

@@ -60,0 +77,0 @@ }

import raf, {cancel} from 'raf'
import now from 'performance-now'
/** Copyright 2011, Joe Lambert.

@@ -7,3 +8,2 @@ ** Free to use under the MIT license.

**/
export const clearRequestTimeout = handle => {

@@ -13,7 +13,7 @@ cancel(handle.value)

export const requestTimeout = (fn, delay) => {
let start = now(),
const start = now(),
handle = {}
const loop = () => {
now() - start >= delay ? fn.call() : (handle.value = raf(loop))
now() - start >= delay ? fn.call(null) : (handle.value = raf(loop))
}

@@ -20,0 +20,0 @@

{
"name": "@essentials/request-timeout",
"version": "1.0.1",
"version": "1.0.2",
"homepage": "https://github.com/jaredLunde/essentials/tree/master/packages/request-timeout#readme",
"repository": "github:jaredLunde/essentials",
"bugs": "https://github.com/jaredLunde/essentials/issues",
"author": "Jared Lunde <jared.lunde@gmail.com> (https://jaredLunde.com)",
"license": "MIT",
"description": "A setTimeout() function that uses requestAnimationFrame() in the background for ticks",
"keywords": [
"request timeout"
],
"main": "dist/cjs/index.js",
"author": "Jared Lunde <jared@BeStellar.co> (https://BeStellar.co)",
"license": "MIT",
"module": "dist/es/index.js",
"files": [
"/dist"
],
"sideEffects": false,
"module": "dist/es/index.js",
"repository": "https://github.com/jaredLunde/essentials/tree/master/packages/request-timeout",
"scripts": {
"build": "yarn run build:es && yarn run build:cjs",
"build:es": "rimraf dist/es && cross-env NODE_ENV=production BABEL_ENV=es babel src --out-dir dist/es && npm run prettier:es",
"build:cjs": "rimraf dist/cjs && cross-env NODE_ENV=production BABEL_ENV=cjs babel src --out-dir dist/cjs && npm run prettier:cjs",
"watch:es": "rimraf dist/es && cross-env NODE_ENV=production BABEL_ENV=es babel src -w --out-dir dist/es",
"prettier": "prettier --single-quote --no-semi --no-bracket-spacing --trailing-comma es5 --write",
"prettier:es": "yarn prettier \"dist/es/**/*.js\"",
"prettier:cjs": "yarn prettier \"dist/cjs/**/*.js\"",
"prepublishOnly": "yarn build"
"build": "npm run build:cjs && npm run build:es && npm run build:types",
"build:cjs": "babel src -d dist/cjs -x .ts --ignore \"**/*.test.ts\",\"**/test.ts\" --delete-dir-on-start",
"build:es": "babel src -d dist/es -x .ts --env-name es --ignore \"**/*.test.ts\",\"**/test.ts\" --delete-dir-on-start",
"build:types": "tsc -p tsconfig.json -d --outDir dist/es --emitDeclarationOnly && mkdir -p dist/cjs && cp -R dist/es/**.d.ts dist/cjs && rimraf dist/**/*.test.d.ts",
"check-types": "tsc --noEmit -p tsconfig.json",
"format": "prettier --write \"**/*.{ts,js,md,yml,json,babelrc,eslintrc,prettierrc}\"",
"lint": "eslint . --ext .ts",
"prepublishOnly": "npm run lint && npm run test && npm run build && npm run format",
"test": "jest",
"validate": "npm run check-types && npm run lint && npm run test -- --coverage"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && npm run build:types"
}
},
"lint-staged": {
"**/*.{ts,js}": [
"eslint",
"prettier --write"
],
"**/*.{md,yml,json}": [
"prettier --write"
]
},
"devDependencies": {
"@stellar-apps/babel-preset-es": "^1.0.4",
"prettier": "^1.16.4",
"rimraf": "^2.6.3"
"@lunde/babel-preset-es": "latest",
"@types/jest": "latest",
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest",
"cross-env": "latest",
"eslint": "latest",
"eslint-import-resolver-jest": "latest",
"eslint-plugin-jest": "latest",
"husky": "latest",
"jest": "latest",
"lint-staged": "latest",
"mock-raf": "^1.0.1",
"prettier": "latest",
"rimraf": "^2.6.3",
"ts-jest": "latest",
"typescript": "latest"
},

@@ -28,3 +66,4 @@ "dependencies": {

"raf": "^3.4.1"
}
},
"peerDependencies": {}
}

@@ -1,10 +0,41 @@

# @react-hook/[packageName]
[description]
<hr>
<div align="center">
<h1 align="center">
@essentials/request-timeout
</h1>
</div>
## Installation
`yarn add @react-hook/[packageName]`
<p align="center">
<a href="https://bundlephobia.com/result?p=@essentials/request-timeout">
<img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/@essentials/request-timeout?style=for-the-badge&labelColor=24292e">
</a>
<a aria-label="Types" href="https://www.npmjs.com/package/@essentials/request-timeout">
<img alt="Types" src="https://img.shields.io/npm/types/@essentials/request-timeout?style=for-the-badge&labelColor=24292e">
</a>
<a aria-label="NPM version" href="https://www.npmjs.com/package/@essentials/request-timeout">
<img alt="NPM Version" src="https://img.shields.io/npm/v/@essentials/request-timeout?style=for-the-badge&labelColor=24292e">
</a>
<a aria-label="License" href="https://jaredlunde.mit-license.org/">
<img alt="MIT License" src="https://img.shields.io/npm/l/@essentials/request-timeout?style=for-the-badge&labelColor=24292e">
</a>
</p>
## Usage
<pre align="center">npm i @essentials/request-timeout</pre>
<hr>
A `setTimeout()` function that uses `requestAnimationFrame()` in the background for ticks
## Quick Start
```js
import _ from '@react-hook/[packageName]'
```
import {requestTimeout, clearRequestTimeout} from '@essentials/request-timeout'
// Has the same API as setTimeout
const handle = requestTimeout(() => {}, 300)
// Has the same API as clearTimeout
clearRequestTimeout(handle)
```
## LICENSE
MIT

Sorry, the diff of this file is not supported yet

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