Skip to content

Instantly share code, notes, and snippets.

View a-bronx's full-sized avatar

Andrey Bronnikov a-bronx

  • HID Global
  • Fremont, CA
View GitHub Profile
@a-bronx
a-bronx / esm-package.md
Created February 10, 2024 07:08 — forked from sindresorhus/esm-package.md
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.
@a-bronx
a-bronx / immutable-operations.spec.js
Created February 10, 2024 07:08 — forked from elliotlarson/immutable-operations.spec.js
JavaScript Immutable Operations on Arrays and Objects
// This is a Jest spec that explores some of the different ways to alter
// arrays and objects without mutating state. I'm trying different approaches
// available using:
//
// * Vanilla JS
// * Immutable.js
// * Lodash
// * Rambda
//
// The motivation for this is largely to work with a Redux store.
@a-bronx
a-bronx / delete_git_submodule.md
Created November 16, 2022 20:47 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@a-bronx
a-bronx / debounce.js
Created June 2, 2020 07:01 — forked from just-boris/debounce.js
small debounce implementation without lodash
export const DEBOUNCE_DEFAULT_DELAY = 200;
export default function debounce(func, delay = DEBOUNCE_DEFAULT_DELAY) {
let timeout;
return function(...args) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
@a-bronx
a-bronx / angularjs_directive_attribute_explanation.md
Created April 28, 2019 02:29 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>