Skip to content

Instantly share code, notes, and snippets.

View Izhaki's full-sized avatar
💭
codinsky

Izhaki

💭
codinsky
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 13, 2024 08:32
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.
@ncochard
ncochard / babel-webpack.md
Last active September 29, 2023 05:15
The correct way to compile ES6 using babel...

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
@MariadeAnton
MariadeAnton / hi-satellite.md
Last active August 7, 2022 18:06
Travis CI Demo Examples - GitHub Satellite 2019
@primaryobjects
primaryobjects / searchInsert.js
Last active August 8, 2020 00:09
Search Insert Position in a sorted array. Find the index of a value in a sorted array or return the index where it should be placed. Searches array using divide and conquer.
/**
* @param {number[]} nums
* @param {number} target
* @return {number}
*/
var searchInsert = function(nums, target) {
var start = 0;
var end = nums.length - 1;
var index = Math.floor((end - start) / 2) + start;
@dchowitz
dchowitz / es6-debugging-in-vscode.md
Last active August 30, 2023 06:23
Debugging ES6 in VS Code

Debugging ES6 in VS Code

My current editor of choice for all things related to Javascript and Node is VS Code, which I highly recommend. The other day I needed to hunt down a bug in one of my tests written in ES6, which at time of writing is not fully supported in Node. Shortly after, I found myself down the rabbit hole of debugging in VS Code and realized this isn't as straightforward as I thought initially. This short post summarizes the steps I took to make debugging ES6 in VS Code frictionless.

What doesn't work

My first approach was a launch configuration in launch.json mimicking tape -r babel-register ./path/to/testfile.js with babel configured to create inline sourcemaps in my package.json. The debugging started but breakpoints and stepping through the code in VS Code were a complete mess. Apparently, ad-hoc transpilation via babel-require-hook and inline sourcemaps do not work in VS Code. The same result for attaching (instead of launch) to `babel-node

@maxdemarzi
maxdemarzi / __usage.adoc
Last active December 8, 2021 10:49 — forked from jexp/__numbers_31.txt
Concurrent Neo4j Performance Tests via HTTP + Cypher (usage: ./_run_ab.sh 4 10000 create_plain.json)

Usage

Use latest Neo4j for best results, e.g. 2.2.2 or 2.3.0-M02 (http://neo4j.com/download) On a machine with 12 cores use concurrency 24

Create 1 node, 1 rel, 1 property per request, 1M requests

Total: 1M nodes, rels, props


@luugiathuy
luugiathuy / slide.html
Created April 6, 2015 10:18
Jekyll layout for reveal.js
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
{% if page.title %}
{{ page.title }} | {{ site.title }}
{% else %}
{{ site.title }}
@staltz
staltz / introrx.md
Last active May 13, 2024 09:59
The introduction to Reactive Programming you've been missing