Skip to content

Instantly share code, notes, and snippets.

View bsdahl's full-sized avatar
🇺🇸

Benjamin Dahl bsdahl

🇺🇸
View GitHub Profile
@bsdahl
bsdahl / areIntersectingKeysEqual.js
Created October 14, 2020 21:26
Function to determine if intersecting keys are equal
export function areIntersectingKeysEqual(...objects) {
return objects
.map((object) => Object.keys(object))
.sort((a, b) => a.length - b.length)
.reduce((a, b) => a.filter((key) => b.includes(key)))
.every((key) => objects.every((object) => object[key] === objects[0][key]));
}
@bsdahl
bsdahl / intersectingKeys.js
Last active October 13, 2020 23:25
Function that will find intersecting keys for n number of object arguments.
export function intersectingKeys(...objects) {
return objects
.map((object) => Object.keys(object))
.sort((a, b) => a.length - b.length)
.reduce((a, b) => a.filter((key) => b.includes(key)));
}
@bsdahl
bsdahl / StaggeredFade.js
Created July 8, 2020 17:59
Staggered Fade animation on React Child Components using react-spring
import React from 'react';
import { animated, useTrail } from 'react-spring';
export const StaggeredFade = ({ children, ...props }) => {
const trail = useTrail(React.Children.count(children), {
from: { opacity: 0 },
to: { opacity: 1 },
config: { mass: 1, tension: 280, friction: 60, clamp: true },
});
@bsdahl
bsdahl / watchdog.js
Created January 28, 2020 06:57
Watchdog timeout utility for aws serverless applications.
export function watchDog(event, context) {
let messageStack = [];
let timeoutId;
const push = function(message) {
messageStack.push(message);
};
const setupTimer = function(event, context, callback) {
messageStack.push('Start');

Keybase proof

I hereby claim:

  • I am bsdahl on github.
  • I am bdahl (https://keybase.io/bdahl) on keybase.
  • I have a public key ASCXTdL8iJnW0gotE4Qv2-E5jZXW7UIvs6B5C5Q0_cdq3wo

To claim this, I am signing this object: