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

@buffetjs/hooks

Package Overview
Dependencies
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@buffetjs/hooks - npm Package Compare versions

Comparing version 3.2.1 to 3.2.2-next.0

babel.config.js

60

dist/index.js

@@ -1,55 +0,59 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
Object.defineProperty(exports, "useActiveKeys", {
Object.defineProperty(exports, 'useActiveKeys', {
enumerable: true,
get: function get() {
return _useActiveKeys["default"];
}
return _useActiveKeys['default'];
},
});
Object.defineProperty(exports, "useClickAwayListener", {
Object.defineProperty(exports, 'useClickAwayListener', {
enumerable: true,
get: function get() {
return _useClickAwayListener["default"];
}
return _useClickAwayListener['default'];
},
});
Object.defineProperty(exports, "useDebounce", {
Object.defineProperty(exports, 'useDebounce', {
enumerable: true,
get: function get() {
return _useDebounce["default"];
}
return _useDebounce['default'];
},
});
Object.defineProperty(exports, "useEventListener", {
Object.defineProperty(exports, 'useEventListener', {
enumerable: true,
get: function get() {
return _useEventListener["default"];
}
return _useEventListener['default'];
},
});
Object.defineProperty(exports, "useIsMounted", {
Object.defineProperty(exports, 'useIsMounted', {
enumerable: true,
get: function get() {
return _useIsMounted["default"];
}
return _useIsMounted['default'];
},
});
Object.defineProperty(exports, "useShortcutEffect", {
Object.defineProperty(exports, 'useShortcutEffect', {
enumerable: true,
get: function get() {
return _useShortcutEffect["default"];
}
return _useShortcutEffect['default'];
},
});
var _useActiveKeys = _interopRequireDefault(require("./useActiveKeys"));
var _useActiveKeys = _interopRequireDefault(require('./useActiveKeys'));
var _useClickAwayListener = _interopRequireDefault(require("./useClickAwayListener"));
var _useClickAwayListener = _interopRequireDefault(
require('./useClickAwayListener')
);
var _useDebounce = _interopRequireDefault(require("./useDebounce"));
var _useDebounce = _interopRequireDefault(require('./useDebounce'));
var _useEventListener = _interopRequireDefault(require("./useEventListener"));
var _useEventListener = _interopRequireDefault(require('./useEventListener'));
var _useIsMounted = _interopRequireDefault(require("./useIsMounted"));
var _useIsMounted = _interopRequireDefault(require('./useIsMounted'));
var _useShortcutEffect = _interopRequireDefault(require("./useShortcutEffect"));
var _useShortcutEffect = _interopRequireDefault(require('./useShortcutEffect'));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}

@@ -1,52 +0,123 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports["default"] = void 0;
exports['default'] = void 0;
var _react = require("react");
var _react = require('react');
var _useEventListener = _interopRequireDefault(require("../useEventListener"));
var _useEventListener = _interopRequireDefault(require('../useEventListener'));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _toConsumableArray(arr) {
return (
_arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread()
);
}
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _nonIterableSpread() {
throw new TypeError('Invalid attempt to spread non-iterable instance');
}
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _iterableToArray(iter) {
if (
Symbol.iterator in Object(iter) ||
Object.prototype.toString.call(iter) === '[object Arguments]'
)
return Array.from(iter);
}
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
arr2[i] = arr[i];
}
return arr2;
}
}
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _slicedToArray(arr, i) {
return (
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
);
}
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _nonIterableRest() {
throw new TypeError('Invalid attempt to destructure non-iterable instance');
}
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _iterableToArrayLimit(arr, i) {
if (
!(
Symbol.iterator in Object(arr) ||
Object.prototype.toString.call(arr) === '[object Arguments]'
)
) {
return;
}
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (
var _i = arr[Symbol.iterator](), _s;
!(_n = (_s = _i.next()).done);
_n = true
) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i['return'] != null) _i['return']();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function useActiveKeys() {
var isEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var isEnabled =
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var _useState = (0, _react.useState)([]),
_useState2 = _slicedToArray(_useState, 2),
activeKeys = _useState2[0],
setActiveKeys = _useState2[1];
_useState2 = _slicedToArray(_useState, 2),
activeKeys = _useState2[0],
setActiveKeys = _useState2[1];
(0, _useEventListener["default"])('keydown', function (e) {
if (!activeKeys.includes(e.keyCode)) {
(0, _useEventListener['default'])(
'keydown',
function (e) {
if (!activeKeys.includes(e.keyCode)) {
setActiveKeys(function (prevKeys) {
return [].concat(_toConsumableArray(prevKeys), [e.keyCode]);
});
}
},
isEnabled
);
(0, _useEventListener['default'])(
'keyup',
function (e) {
setActiveKeys(function (prevKeys) {
return [].concat(_toConsumableArray(prevKeys), [e.keyCode]);
return prevKeys.filter(function (key) {
return key !== e.keyCode;
});
});
}
}, isEnabled);
(0, _useEventListener["default"])('keyup', function (e) {
setActiveKeys(function (prevKeys) {
return prevKeys.filter(function (key) {
return key !== e.keyCode;
});
});
}, isEnabled);
},
isEnabled
);
return activeKeys;

@@ -56,2 +127,2 @@ }

var _default = useActiveKeys;
exports["default"] = _default;
exports['default'] = _default;

@@ -1,9 +0,9 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports["default"] = void 0;
exports['default'] = void 0;
var _react = require("react");
var _react = require('react');

@@ -26,2 +26,2 @@ var useClickAwayListener = function useClickAwayListener(ref, callback) {

var _default = useClickAwayListener;
exports["default"] = _default;
exports['default'] = _default;

@@ -1,32 +0,76 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports["default"] = void 0;
exports['default'] = void 0;
var _react = require("react");
var _react = require('react');
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _slicedToArray(arr, i) {
return (
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
);
}
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _nonIterableRest() {
throw new TypeError('Invalid attempt to destructure non-iterable instance');
}
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _iterableToArrayLimit(arr, i) {
if (
!(
Symbol.iterator in Object(arr) ||
Object.prototype.toString.call(arr) === '[object Arguments]'
)
) {
return;
}
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (
var _i = arr[Symbol.iterator](), _s;
!(_n = (_s = _i.next()).done);
_n = true
) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i['return'] != null) _i['return']();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
var useDebounce = function useDebounce(value, delay) {
var _useState = (0, _react.useState)(value),
_useState2 = _slicedToArray(_useState, 2),
debouncedValue = _useState2[0],
setDebouncedValue = _useState2[1];
_useState2 = _slicedToArray(_useState, 2),
debouncedValue = _useState2[0],
setDebouncedValue = _useState2[1];
(0, _react.useEffect)(function () {
var handler = setTimeout(function () {
setDebouncedValue(value);
}, delay);
return function () {
clearTimeout(handler);
};
}, [value, delay]);
(0, _react.useEffect)(
function () {
var handler = setTimeout(function () {
setDebouncedValue(value);
}, delay);
return function () {
clearTimeout(handler);
};
},
[value, delay]
);
return debouncedValue;

@@ -36,2 +80,2 @@ };

var _default = useDebounce;
exports["default"] = _default;
exports['default'] = _default;

@@ -1,32 +0,36 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports["default"] = void 0;
exports['default'] = void 0;
var _react = require("react");
var _react = require('react');
function useEventListener(event, eventListener) {
var isEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var isEnabled =
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var listenerRef = (0, _react.useRef)();
listenerRef.current = eventListener;
(0, _react.useEffect)(function () {
function handleEvent(e) {
listenerRef.current(e);
}
(0, _react.useEffect)(
function () {
function handleEvent(e) {
listenerRef.current(e);
}
if (isEnabled) {
window.addEventListener(event, handleEvent);
} else {
window.removeEventListener(event, handleEvent);
}
if (isEnabled) {
window.addEventListener(event, handleEvent);
} else {
window.removeEventListener(event, handleEvent);
}
return function () {
window.removeEventListener(event, handleEvent);
};
}, [event, isEnabled]);
return function () {
window.removeEventListener(event, handleEvent);
};
},
[event, isEnabled]
);
}
var _default = useEventListener;
exports["default"] = _default;
exports['default'] = _default;

@@ -1,9 +0,9 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports["default"] = void 0;
exports['default'] = void 0;
var _react = require("react");
var _react = require('react');

@@ -22,2 +22,2 @@ function useIsMounted() {

var _default = useIsMounted;
exports["default"] = _default;
exports['default'] = _default;

@@ -1,13 +0,15 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
exports["default"] = void 0;
exports['default'] = void 0;
var _react = require("react");
var _react = require('react');
var _useActiveKeys = _interopRequireDefault(require("../useActiveKeys"));
var _useActiveKeys = _interopRequireDefault(require('../useActiveKeys'));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}

@@ -20,3 +22,3 @@ var keyCodes = {

f: 70,
tab: 9
tab: 9,
};

@@ -31,18 +33,22 @@

function useShortcutEffect(shortcut, listener) {
var isEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var activeKeys = (0, _useActiveKeys["default"])(isEnabled);
var isEnabled =
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var activeKeys = (0, _useActiveKeys['default'])(isEnabled);
var listenerRef = (0, _react.useRef)();
listenerRef.current = listener;
(0, _react.useEffect)(function () {
var match = getShortcutKeys(shortcut).every(function (key) {
return activeKeys.includes(key);
});
(0, _react.useEffect)(
function () {
var match = getShortcutKeys(shortcut).every(function (key) {
return activeKeys.includes(key);
});
if (match) {
listenerRef.current();
}
}, [activeKeys, shortcut]);
if (match) {
listenerRef.current();
}
},
[activeKeys, shortcut]
);
}
var _default = useShortcutEffect;
exports["default"] = _default;
exports['default'] = _default;
{
"name": "@buffetjs/hooks",
"version": "3.2.1",
"version": "3.2.2-next.0",
"description": "Buffetjs react-hooks",
"main": "dist/index.js",
"module": "src/index.js",
"files": [
"dist/*"
"main": "build",
"module": "build/esm/index.js",
"sideEffects": [
"*.css"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "cross-env NODE_ENV=production rimraf dist && babel --config-file ../../.babelrc src --out-dir dist --copy-files --no-comments && rimraf dist/**/**/tests",
"lint": "eslint --c ../../.eslintrc src",
"prepublishOnly": "npm run build",
"watch": "babel --config-file ../../.babelrc src --watch --out-dir dist --copy-files --no-comments && rimraf dist/**/**/tests"
"prebuild": "rimraf build",
"build": "yarn build:development && yarn build:production && yarn build:esm",
"build:analyze": "cross-env NODE_ENV=production webpack-cli --json > build/stats.production.json && webpack-bundle-analyzer build/stats.production.json",
"build:development": "cross-env NODE_ENV=development webpack-cli",
"build:esm": "cross-env BABEL_ENV=esm babel ./src --out-dir ./build/esm --ignore \"**/*.test.js\" --ignore \"**/test.js\" ",
"build:production": "cross-env NODE_ENV=production APP_ENV=production webpack-cli",
"build:watch": "cross-env NODE_ENV=development APP_ENV=development webpack-cli -w",
"test": "yarn run test:lint",
"test:lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "npm run build"
},

@@ -20,4 +26,35 @@ "license": "MIT",

"devDependencies": {
"jest-styled-components": "^7.0.0",
"react": "^16.12.0"
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.1.6",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"babel-plugin-module-resolver": "3.0.0",
"bundlesize": "^0.17.0",
"cross-env": "^5.1.4",
"enzyme": "^3.10.0",
"eslint": "^7.5.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-lerna": "^1.1.0",
"eslint-import-resolver-webpack": "^0.12.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.19.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"rimraf": "^3.0.2",
"url-loader": "^1.0.1",
"webpack": "~4.44.0",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "~3.3.12"
},

@@ -41,3 +78,3 @@ "peerDependencies": {

},
"gitHead": "bde769f980b1385b707e443dcca49585b7cbe0c0"
"gitHead": "1e8323f38e59122c3e3a4a6e0c872b3d66b270e8"
}
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