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.2 to 1.2.0

2

dist/cjs/index.d.ts
export interface RequestTimeoutHandle {
value?: number
v?: number
}

@@ -4,0 +4,0 @@ /** Copyright 2011, Joe Lambert.

@@ -6,52 +6,4 @@ 'use strict'

var _raf = _interopRequireWildcard(require('raf'))
var _raf = require('@essentials/raf')
var _performanceNow = _interopRequireDefault(require('performance-now'))
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj}
}
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
}
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
if (cache) {
cache.set(obj, newObj)
}
return newObj
}
/** Copyright 2011, Joe Lambert.

@@ -62,3 +14,3 @@ ** Free to use under the MIT license.

const clearRequestTimeout = handle => {
;(0, _raf.cancel)(handle.value)
;(0, _raf.caf)(handle.v || -1)
}

@@ -69,12 +21,12 @@

const requestTimeout = (fn, delay) => {
const start = (0, _performanceNow.default)(),
const start = (0, _raf.now)(),
handle = {}
const loop = () => {
;(0, _performanceNow.default)() - start >= delay
;(0, _raf.now)() - start >= delay
? fn.call(null)
: (handle.value = (0, _raf.default)(loop))
: (handle.v = (0, _raf.raf)(loop))
}
handle.value = (0, _raf.default)(loop)
handle.v = (0, _raf.raf)(loop)
return handle

@@ -81,0 +33,0 @@ }

export interface RequestTimeoutHandle {
value?: number
v?: number
}

@@ -4,0 +4,0 @@ /** Copyright 2011, Joe Lambert.

@@ -1,3 +0,2 @@

import raf, {cancel} from 'raf'
import now from 'performance-now'
import {raf, caf, now} from '@essentials/raf'

@@ -9,3 +8,3 @@ /** Copyright 2011, Joe Lambert.

export const clearRequestTimeout = handle => {
cancel(handle.value)
caf(handle.v || -1)
}

@@ -17,8 +16,8 @@ export const requestTimeout = (fn, delay) => {

const loop = () => {
now() - start >= delay ? fn.call(null) : (handle.value = raf(loop))
now() - start >= delay ? fn.call(null) : (handle.v = raf(loop))
}
handle.value = raf(loop)
handle.v = raf(loop)
return handle
}
export default requestTimeout
{
"name": "@essentials/request-timeout",
"version": "1.0.2",
"version": "1.2.0",
"homepage": "https://github.com/jaredLunde/essentials/tree/master/packages/request-timeout#readme",

@@ -64,6 +64,5 @@ "repository": "github:jaredLunde/essentials",

"dependencies": {
"performance-now": "^2.1.0",
"raf": "^3.4.1"
"@essentials/raf": "^1.1.2"
},
"peerDependencies": {}
}
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