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

@symbolic/lib

Package Overview
Dependencies
Maintainers
4
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@symbolic/lib - npm Package Compare versions

Comparing version 1.0.27 to 1.0.28

src/event/event.js

113

dist/index.js

@@ -8,3 +8,3 @@ 'use strict';

var axios = _interopDefault(require('axios'));
var _ = _interopDefault(require('lodash'));
var _$1 = _interopDefault(require('lodash'));
var Cookies = _interopDefault(require('js-cookie'));

@@ -34,3 +34,3 @@

if (shouldAlert && !isReactNative) {
alert(_.join(_.map(error.response.data.errors, 'message'), `\n`));
alert(_$1.join(_$1.map(error.response.data.errors, 'message'), `\n`));
}

@@ -40,3 +40,3 @@

throw new Error(_.get(error, 'response.data.errors.0.message', 'Something went wrong'));
throw new Error(_$1.get(error, 'response.data.errors.0.message', 'Something went wrong'));
}

@@ -50,3 +50,3 @@

return _.get(response, 'data');
return _$1.get(response, 'data');
},

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

return _.get(response, `data.resources.${actionKey}.${resourceKey}`);
return _$1.get(response, `data.resources.${actionKey}.${resourceKey}`);
},

@@ -78,32 +78,2 @@

var time = {};
time.scales = [
{abbreviation: 'm', title: 'minute', minutes: 1, maxMinutes: 59},
{abbreviation: 'h', title: 'hour', minutes: 60, maxMinutes: 479},
{abbreviation: 'd', title: 'day', minutes: 480, maxMinutes: 2399},
{abbreviation: 'w', title: 'week', minutes: 2400, maxMinutes: 10079},
{abbreviation: 'mo', title: 'month', minutes: 10080, maxMinutes: 125279},
{abbreviation: 'y', title: 'year', minutes: 125280}
];
time.toLabel = (minutes) => {
minutes = Math.round(minutes) || 0; //HINT prevent invalid minutes values
var scale = _.find(time.scales, scale => minutes <= scale.maxMinutes) || _.last(time.scales);
var number = Math.round(minutes/scale.minutes * 10) / 10;
return `${number}${scale.abbreviation}`;
};
time.toMinutes = (label) => {
label = label || '0m';
var number = parseFloat(label) || 0;
var abbreviation = label.replace(`${number}`, '');
var scale = _.find(time.scales, {abbreviation});
return scale && number ? (number * scale.minutes) : 0;
};
var colors = {};

@@ -161,2 +131,72 @@

var libEvent = {
keyPressed(event, key) {
var keyCode = event.keyCode;
var pressed = false;
if (key === 'left') pressed = keyCode === 37;
if (key === 'up') pressed = keyCode === 38;
if (key === 'right') pressed = keyCode === 39;
if (key === 'down') pressed = keyCode === 40;
if (key === 'c') pressed = keyCode === 67;
if (key === 's') pressed = keyCode === 83;
if (key === 'v') pressed = keyCode === 86;
if (key === 'x') pressed = keyCode === 88;
if (key === 'y') pressed = keyCode === 89;
if (key === 'z') pressed = keyCode === 90;
if (key === '+') pressed = keyCode === 187;
if (key === '-') pressed = keyCode === 189;
if (key === 'enter') pressed = keyCode === 13;
if (key === 'ctrlcmd') pressed = (event.ctrlKey || event.metaKey || event.which === 22 || event.which === 224);
if (key === 'alt') pressed = (event.altKey);
if (key === 'esc') pressed = keyCode === 27;
if (key === 'tab') pressed = keyCode === 9;
if (key === 'shift') pressed = event.shiftKey;
if (key === 'backspace') pressed = keyCode === 8;
if (key === 'space') pressed = keyCode === 32;
if (key === 'delete') pressed = keyCode === 8 || keyCode === 46;
return pressed;
},
numberKeyPressed(event) {
var numberKeyCodes = [49, 50, 51, 52, 53, 54, 55, 56, 57, 48];
var keyCode = event.keyCode;
return _.includes(numberKeyCodes, keyCode);
}
};
var time = {};
time.scales = [
{abbreviation: 'm', title: 'minute', minutes: 1, maxMinutes: 59},
{abbreviation: 'h', title: 'hour', minutes: 60, maxMinutes: 479},
{abbreviation: 'd', title: 'day', minutes: 480, maxMinutes: 2399},
{abbreviation: 'w', title: 'week', minutes: 2400, maxMinutes: 10079},
{abbreviation: 'mo', title: 'month', minutes: 10080, maxMinutes: 125279},
{abbreviation: 'y', title: 'year', minutes: 125280}
];
time.toLabel = (minutes) => {
minutes = Math.round(minutes) || 0; //HINT prevent invalid minutes values
var scale = _$1.find(time.scales, scale => minutes <= scale.maxMinutes) || _$1.last(time.scales);
var number = Math.round(minutes/scale.minutes * 10) / 10;
return `${number}${scale.abbreviation}`;
};
time.toMinutes = (label) => {
label = label || '0m';
var number = parseFloat(label) || 0;
var abbreviation = label.replace(`${number}`, '');
var scale = _$1.find(time.scales, {abbreviation});
return scale && number ? (number * scale.minutes) : 0;
};
var validation = {};

@@ -170,3 +210,3 @@

var sf = {api, colors, validation, time};
var sf = {api, colors, event: libEvent, validation, time};

@@ -176,3 +216,4 @@ exports.api = api;

exports.default = sf;
exports.event = libEvent;
exports.time = time;
exports.validation = validation;
{
"name": "@symbolic/lib",
"version": "1.0.27",
"version": "1.0.28",
"description": "plain js utilities",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import api from './api/api';
import colors from './colors/colors';
import event from './event/event';
import time from './time/time';
import colors from './colors/colors';
import validation from './validation/validation';
var sf = {api, colors, validation, time};
var sf = {api, colors, event, validation, time};
export default sf;
export {api, colors, validation, time};
export {api, colors, event, validation, time};
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