Skip to content

Instantly share code, notes, and snippets.

@HynekS
HynekS / check-packages.js
Created March 21, 2024 07:56 — forked from simon360/check-packages.js
Compare different package.json files in a monorepo to see if dependency versions differ
const chalk = require("chalk");
const packages = [
require("./package.json"),
require("./packages/cec-scripts/package.json"),
require("./packages/generator-cec/package.json"),
require("./packages/utility-cec-simulator/package.json")
];
const compareDeps = p => {
@HynekS
HynekS / api.ts
Created March 6, 2024 20:37 — forked from DouglasdeMoura/api.ts
Tiny wrapper around fetch
// Extends the return of the HTTPError class
class HTTPError extends Error {
readonly response: any;
readonly status: number;
readonly statusText: string;
constructor(status: number, statusText: string, response: any) {
super(statusText);
this.status = status;
this.statusText = statusText;
@HynekS
HynekS / api.js
Created March 6, 2024 20:07 — forked from giacomocerquone/api.js
Handy thin wrapper around the fetch Api
const _toQueryString = params =>
`?${Object.entries(params)
.map(
([key, value]) =>
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
)
.join("&")}`;
// EDIT here if you prefer a storage implementation or a store subscription etc.
// you could actually also remove the getToken function and directly call it in the header below
@HynekS
HynekS / gatsby-browser.js
Last active April 20, 2020 10:34 — forked from azamatsmith/gatsby-browser.js
Adding Redux to Gatsby - with devtools and redux-thunk
import React from 'react';
import { Provider } from 'react-redux';
import { applyMiddleware, compose, createStore } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './src/reducers';
const loadDevTools = () =>
process.env.NODE_ENV === 'development' && typeof window !== 'undefined' && window.devToolsExtension
? window.__REDUX_DEVTOOLS_EXTENSION__ &&
window.__REDUX_DEVTOOLS_EXTENSION__()