Skip to content

Instantly share code, notes, and snippets.

View Raiondesu's full-sized avatar
🐢
Slow to respond

Alexey Iskhakov Raiondesu

🐢
Slow to respond
View GitHub Profile
@Raiondesu
Raiondesu / isProxy.js
Created September 16, 2020 12:01
Check if JS object is a proxy
// Credit to https://stackoverflow.com/a/49651719 and https://stackoverflow.com/a/60323358
const isProxy = obj => {
try {
postMessage(obj, window);
} catch (error) {
return error && error.code === 25;
}
return false;
@Raiondesu
Raiondesu / machine.js
Created November 26, 2019 06:48
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@Raiondesu
Raiondesu / examples.ts
Last active September 17, 2019 20:21
Simple TypeScript pattern matching
const t1 = match(2) (_ => [
[
Number,
_ => 'number!'
],
[
_ > 3,
_ => _ + 3
],
[
@Raiondesu
Raiondesu / regexpFromStr.js
Last active September 30, 2018 20:41
A simple function that parses a JS regular expression from a string
export default strRegExp => {
const flags = strRegExp.replace(/.*\/([gimy]*)$/, '$1');
const pattern = strRegExp.replace(new RegExp('^/(.*?)/'+flags+'$'), '$1');
return new RegExp(pattern, flags);
}
@Raiondesu
Raiondesu / flexgrid.less
Last active September 26, 2018 14:57
Small flexgrid using Less
@media-unit: rem;
.with-unit(@v) { @r: ~'@{v}@{media-unit}'; }
@all: {
@value: 0;
@with-unit: auto;
width: auto;
media: ~'screen and (min-width: @{value})';
};
@Raiondesu
Raiondesu / README.md
Last active September 10, 2020 12:14
Object path manipulators: simple get & set via a path w/o exceptions. Also works with numbered indecies (and nested arrays);

fromPath

const obj = {
  2: 3,
  very: {
    nested: {
      object: {
        here: '!'
      }
@Raiondesu
Raiondesu / AbortableFetch.ts
Last active December 2, 2023 13:20
A simple and usable abortable web (fetch, promise) realization in TypeScript
import AbortablePromise from './abortablePromise';
export default function abortableFetch(input?: string | Request, init?: RequestInit) {
const signal = init ? init.signal : input ? input['signal'] : undefined;
const abortController = signal ? undefined : new AbortController();
const promise = new AbortablePromise<Response>(fetch.apply(arguments), abortController);
if (signal) {
promise.signal = signal;

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a