Skip to content

Instantly share code, notes, and snippets.

View JoviDeCroock's full-sized avatar
🐨

Jovi De Croock JoviDeCroock

🐨
View GitHub Profile
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css'
class Square extends React.Component {
render() {
return (
<button className="square" onClick={() => this.props.onClick()}>
{this.props.value}
</button>
const inputArray = [[1, 2, [3]], 4];
const flatten = input => {
return input.reduce((acc, x) => {
if (Array.isArray(x)) {
return [...acc, ...flatten(x)];
} else {
return [...acc, x];
}
}, []);
import * as React from 'react';
import { connect } from 'react-redux';
import { sendMutationAction } from '@bucket/actions/genericActions';
import { getMutationDataFactorySelector } from '@bucket/selectors/genericSelectors';
/**
* This component has the sole purpose of executing a Mutation
* to achieve this it will go through some steps
*
* - Render: It will bind a function according to the passed parameters.

Modern applications

Most JavaScript developers love making modern applications, with our new language features and latest libraries making our life easier, but has any one ever actually wondered if this ever impacts our users.

We are dealing with abstractions, abstractions are trying to cover a general use case which could not be conforming to yours. Some are over-engineered in ways one can't possibly comprehend, use cases that will never be reached by middle sized applications. Some of these over

const seen = []
function traverseObject(obj) {
Object.keys(obj).reduce((acc, key) => {
const value = obj[key];
if (typeof value !== 'object) return { ...acc, [key]: value };
if (Array.isArray(value) {
return { ...acc, [key]: value.map(traverseObject) }
}
import { Exchange } from 'urql';
import { fromDomEvent, subscribe, pipe, filter } from 'wonka';
export const offlineExchange = (): Exchange => ({
forward,
client,
}) => {
const queue = [];
const flushQueue = () => {
#!/usr/bin/env node
export function foo() {
return 'hello world';
}

Problem

Imagine a scenario where we dispatch two requests one to get our Todo named Q and one to toggle our todo to completed named M1.

Q1 will return:

{
  id: 1
 name: 'make graphcache updates idempotent',

Strict-equality

When creating elements and passing them as children we can have scenario's where we don't have to diff the children because it will still be the same vnode.

Imagine the following scenario:

const context = createContext(null);
const App = () => (
@JoviDeCroock
JoviDeCroock / *cjyes.md
Created May 20, 2020 18:50 — forked from developit/*cjyes.md
more-or-less instant command-line ESM to CJS transform. Copies from src to dist. `cjyes src/*.js`

cjyes npm version

🔍 see jay, yes! 🎉 / 👨🏻‍💻 see, JS! 👾 / ⚓️ sea JS ⛴

If you're publishing ES Modules, you need to also publish CommonJS versions of those modules.

This isn't to support old browsers or Node versions: even in Node 14, using require() to load a module won't work if it's only available as ESM.

cjyes is the bare minimum fix for this problem. You write ES Modules and fill out a valid package.json, and it'll generate the corresponding CommonJS files pretty much instantly. cjyes takes up 500kb of disk space including its two dependencies.