Skip to content

Instantly share code, notes, and snippets.

View gregdeane's full-sized avatar

Greg Deane gregdeane

  • Berlin, Germany
  • 01:55 (UTC +02:00)
View GitHub Profile

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@unr
unr / vscode-settings.json
Created January 3, 2019 21:30
Example of unr's vetur-focused vim-setup in vscode.
{
// editor settings
"editor.formatOnSave": true,
"editor.renderWhitespace": "all",
"editor.fontSize": 14,
"editor.fontWeight": "500",
"editor.lineHeight": 28,
"editor.letterSpacing": 0,
"editor.fontFamily": "Hack",
"editor.insertSpaces": false,
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active June 2, 2024 11:24
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@sindresorhus
sindresorhus / esm-package.md
Last active June 17, 2024 22:35
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.