Skip to content

Instantly share code, notes, and snippets.

View Shamilik's full-sized avatar
🐈‍⬛
💨

Shamil Yakupov Shamilik

🐈‍⬛
💨
View GitHub Profile
@plukevdh
plukevdh / objectDiff.js
Last active April 11, 2022 13:56
Ramda - Compact diff output for complex objects.
import R from 'ramda'
const isObject = R.compose(R.equals('Object'), R.type);
const allAreObjects = R.compose(R.all(isObject), R.values);
const hasLeft = R.has('left');
const hasRight = R.has('right');
const hasBoth = R.both(hasLeft, hasRight);
const isEqual = R.both(hasBoth, R.compose(R.apply(R.equals), R.values));
const markAdded = R.compose(R.append(undefined), R.values);
@phenomnomnominal
phenomnomnominal / identifier-inside-a-call-expression-example.ts
Created September 16, 2018 05:41
Walking a TypeScript AST and looking for an Identifier inside a CallExpression
import { AbstractWalker } from 'tslint';
import { forEachChild, Node, SourceFile, SyntaxKind } from 'typescript';
class NoFDescribeOrFItWalker extends AbstractWalker {
public walk (sourceFile: SourceFile) {
const walkNode = (node: Node): void => {
if (node.kind === SyntaxKind.CallExpression) {
if (node.expression.kind === SyntaxKind.Identifier) {
// possible rule match!
}
@sindresorhus
sindresorhus / esm-package.md
Last active July 23, 2024 10:30
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.