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.2-next.1 to 3.2.3

60

dist/index.js

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

'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,123 +0,56 @@

'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) || _unsupportedIterableToArray(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.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) {
if (
Symbol.iterator in Object(iter) ||
Object.prototype.toString.call(iter) === '[object Arguments]'
)
return Array.from(iter);
}
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) 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)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) {
return (
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
);
}
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(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.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
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 _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) 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 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)) {
setActiveKeys(function (prevKeys) {
return [].concat(_toConsumableArray(prevKeys), [e.keyCode]);
});
}
},
isEnabled
);
(0, _useEventListener['default'])(
'keyup',
function (e) {
(0, _useEventListener["default"])('keydown', function (e) {
if (!activeKeys.includes(e.keyCode)) {
setActiveKeys(function (prevKeys) {
return prevKeys.filter(function (key) {
return key !== e.keyCode;
});
return [].concat(_toConsumableArray(prevKeys), [e.keyCode]);
});
},
isEnabled
);
}
}, isEnabled);
(0, _useEventListener["default"])('keyup', function (e) {
setActiveKeys(function (prevKeys) {
return prevKeys.filter(function (key) {
return key !== e.keyCode;
});
});
}, isEnabled);
return activeKeys;

@@ -127,2 +60,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,76 +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 _slicedToArray(arr, i) {
return (
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
);
}
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(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.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
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 _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) 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; }
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;

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

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

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

'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,15 +0,13 @@

'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 }; }

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

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

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

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.2-next.1",
"version": "3.2.3",
"description": "Buffetjs react-hooks",
"main": "build",
"module": "build/esm/index.js",
"sideEffects": [
"*.css"
"main": "dist/index.js",
"module": "src/index.js",
"files": [
"dist/*"
],
"scripts": {
"prebuild": "rimraf build",
"build": "yarn build:development && yarn build:production && yarn build:esm && yarn create:index",
"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 webpack-cli",
"build:watch": "yarn create:index && cross-env NODE_ENV=development webpack-cli -w",
"build:watch:esm": "cross-env BABEL_ENV=esm babel ./src --out-dir ./build/esm --ignore \"**/*.test.js\" --ignore \"**/test.js\" --watch",
"create:index": "node ./createBuildIndex.js",
"test": "yarn run test:lint",
"test:lint": "eslint .",
"test:lint:quiet": "eslint . --quiet",
"lint:fix": "eslint . --fix",
"prepublishOnly": "npm run build"
"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"
},

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

"devDependencies": {
"@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"
"jest-styled-components": "^7.0.0",
"react": "^16.12.0"
},

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

},
"gitHead": "6a4838b328f1bfc7262e33f63d53b7385880f56f"
"gitHead": "0c83c30e01cf5ff760c3d7cac82c8719ae061552"
}

@@ -22,30 +22,1 @@ # Buffet.js Hooks

```
### Available commands
- **build**<br/>
Builds the library for production
- **build:analyze**<br/>
Analyse the generated build
- **build:watch**<br/>
Whatch the files with webpack
- **build:watch:esm**<br/>
Whatch the files with babel
- **create:index**<br/>
Create the `build/index.js` file
- **test**<br/>
Runs the entire set of test: lint, style and jest
- **test:jest**<br/>
Runs the unit tests
- **test:jest:watch**<br/>
Runs the unit tests in watch mode
- **test:lint**<br/>
Runs the lint tests
- **test:lint:quiet**<br/>
Runs the lint tests without displaying the warnings
- **test:style**<br/>
Runs the stylelint tests
- **test:style:quiet**<br/>
Runs the stylelint tests without displaying the warnings
- **lint:fix**<br/>
Fixes the lint
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