Skip to content

Commit

Permalink
perf: ⚡️ upgrade throttle-debounce lib, fix tests after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Sep 30, 2018
1 parent c050afd commit a8da481
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"semantic-release": "semantic-release"
},
"dependencies": {
"throttle-debounce": "^1.0.1",
"throttle-debounce": "^2.0.1",
"nano-css": "^1.13.0",
"screenfull": "^3.3.2",
"fast-af": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/IdleSensor/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component} from 'react';
import {render, createEnhancer} from 'react-universal-interface';
import {on, off, noop} from '../util';
import * as throttle from 'throttle-debounce/throttle';
import {throttle} from 'throttle-debounce';

const equalSets = (a: string[], b: string[]) => {
if (a.length !== b.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/LocalStorage/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component} from 'react';
import {get, set, del} from './local-storage';
const debounce = require('throttle-debounce/debounce');
import {debounce} from 'throttle-debounce';

export interface ILocalStorageProps {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/Parallax/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {render} from 'react-universal-interface';
import {IUniversalInterfaceProps} from '../typing';
import {noop, on, off} from '../util';
import {getElRect, getRootRect, TRect} from '../ViewportScrollSensor';
const throttle = require('throttle-debounce/throttle');
import {throttle} from 'throttle-debounce';

const zeros: TRect = [0, 0, 0, 0];

Expand Down
2 changes: 1 addition & 1 deletion src/Slider/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import {noop, on, off} from '../util';
import renderProp from '../util/renderProp';
const throttle = require('throttle-debounce/throttle');
import {throttle} from 'throttle-debounce';

export interface ISliderProps {
children?: React.ReactElement<any> | ((state: ISliderState) => React.ReactElement<any>);
Expand Down
6 changes: 3 additions & 3 deletions src/SyncSensor/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Component} from 'react';
import * as React from 'react';
import {noop} from '../util';
import renderProp from '../util/renderProp';
import * as throttle from 'throttle-debounce/throttle';
import {throttle} from 'throttle-debounce';

export interface ISyncSensorProps<TState> {
throttle?: number;
Expand All @@ -13,7 +13,7 @@ export interface ISyncSensorProps<TState> {
onEvent: (event) => TState;
}

export class SyncSensor<TState> extends Component<ISyncSensorProps<TState>, TState> {
export class SyncSensor<TState> extends React.Component<ISyncSensorProps<TState>, TState> {
static defaultProps = {
throttle: 100
};
Expand Down
2 changes: 1 addition & 1 deletion src/ViewportScrollSensor/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, cloneElement, SFCElement} from 'react';
import {on, off, noop} from '../util';
import * as throttle from 'throttle-debounce/throttle';
import {throttle} from 'throttle-debounce';
import renderProp from '../util/renderProp';
import {IUniversalInterfaceProps} from '../typing';

Expand Down
4 changes: 2 additions & 2 deletions src/WindowScrollSensor/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from 'react';
import * as React from 'react';
import {SyncSensor} from '../SyncSensor';
import {isClient, h} from '../util';
import faccToHoc from '../util/faccToHoc';
Expand Down Expand Up @@ -36,7 +36,7 @@ const getInitialState = () => {
}
};

export class WindowScrollSensor extends Component<IWindowScrollSensorProps, any> {
export class WindowScrollSensor extends React.Component<IWindowScrollSensorProps, any> {
initial = getInitialState();

render () {
Expand Down
2 changes: 1 addition & 1 deletion src/WindowWidthSensor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import faccToHoc from '../util/faccToHoc';
import renderProp from '../util/renderProp';
import {IUniversalInterfaceProps} from '../typing'
import {noop, on, off} from '../util';
const throttle = require('throttle-debounce/throttle');
import {throttle} from 'throttle-debounce';

export interface IWindowWidthSensorProps extends IUniversalInterfaceProps<IWindowWidthSensorState> {
width?: number,
Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createElement} from 'react';
import * as React from 'react';

export type TComponent<TProps> = React.ComponentClass<TProps> | React.StatelessComponent<TProps>;
export type THoc<P1, P2> = (Comp: TComponent<P1>) => TComponent<P2>
Expand Down Expand Up @@ -29,4 +29,4 @@ export const sym = (name) => {

export const isFn = (fn) => typeof fn === 'function';

export const h = createElement as any;
export const h = React.createElement;
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10254,9 +10254,9 @@ throat@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"

throttle-debounce@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-1.1.0.tgz#51853da37be68a155cb6e827b3514a3c422e89cd"
throttle-debounce@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-2.0.1.tgz#7307ddd6cd9acadb349132fbf6c18d78c88a5e62"

through2@^2.0.0, through2@^2.0.2, through2@~2.0.0:
version "2.0.3"
Expand Down

0 comments on commit a8da481

Please sign in to comment.