This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface IHasNeighbours<T> { | |
getNeighbours(): Iterable<T>; | |
} | |
export class AStar { | |
static findPath<T extends IHasNeighbours<T>>(start: T, end: T, distanceFunc: (a: T, b: T) => number, estimateFunc?: (a: T) => number): Array<T> { | |
estimateFunc ??= (a: T) => distanceFunc(a, end); | |
const closed = new Set<T>(); | |
const queue = new PriorityQueue<NodeWithNumber<Path<T>>>(NodeWithNumber.comparator); | |
queue.push(new NodeWithNumber(new Path<T>(start, undefined, 0), 0)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cols = 5; //columns in the grid | |
let rows = 5; //rows in the grid | |
let grid = new Array(cols); //array of all the grid points | |
let openSet = []; //array containing unevaluated grid points | |
let closedSet = []; //array containing completely evaluated grid points | |
let start; //starting grid point | |
let end; // ending grid point (goal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// via: https://github.com/philipwalton/blog/blob/03452d29533cbc85fe863b5917f43cf1638a8236/_scripts/analytics.js#L7-L42 | |
var breakpoints = { | |
xs: '(max-width: 419px)', | |
sm: '(min-width: 420px) and (max-width: 569px)', | |
md: '(min-width: 570px) and (max-width: 799px)', | |
lg: '(min-width: 800px) and (max-width: 999px)', | |
xl: '(min-width: 1000px)' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Made by Elly Loel - https://ellyloel.com/ | |
With inspiration from: | |
- Josh W Comeau - https://courses.joshwcomeau.com/css-for-js/treasure-trove/010-global-styles/ | |
- Andy Bell - https://piccalil.li/blog/a-modern-css-reset/ | |
- Adam Argyle - https://unpkg.com/open-props@1.3.16/normalize.min.css / https://codepen.io/argyleink/pen/KKvRORE | |
Notes: | |
- `:where()` is used to lower specificity for easy overriding. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
watch(arrayToWatch, (newVal, oldVal = []) => { | |
const difference = newVal?.filter(x => !oldVal?.includes(x)) || []; | |
console.log('difference', difference); | |
const symmetricDifference = newVal?.filter((x) => !oldVal?.includes(x)) | |
.concat(oldVal?.filter((x) => !newVal?.includes(x))) || []; | |
console.log('symetricDifference', symmetricDifference); | |
if (difference?.length > 0) { | |
emit('add-item', difference[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a super basic way of mapping Vue props to argTypes in cases | |
// where Storybook (or rather vue-docgen-api) fails. | |
// See https://github.com/storybookjs/storybook/issues/11774 | |
const toType = (obj) => ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() | |
const controlTypeMappings = { | |
String: 'text', | |
Boolean: 'boolean', | |
Array: 'object', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Filters an array of objects using custom predicates. | |
* | |
* @param {Array} array: the array to filter | |
* @param {Object} filters: an object with the filter criteria | |
* @return {Array} | |
*/ | |
function filterArray(array, filters) { | |
const filterKeys = Object.keys(filters); | |
return array.filter(item => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<slot/> | |
</div> | |
</template> | |
<script> | |
// @ts-check | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -------------------------------- | |
Typography | |
-------------------------------- */ | |
:root { | |
--font-primary: sans-serif; | |
--font-secondary: serif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const modifierClasses = (vm) => ((root) => { | |
if (vm.modifier) { | |
const classArray = (typeof vm.modifier === 'string') | |
? new Array(vm.modifier) | |
: [...vm.modifier]; | |
return classArray.map((modifier) => `${root}--${modifier}`); | |
} | |
return null; | |
}); |
NewerOlder