The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'instead ofconst foo = require('foo')to import the package. You also need to put"type": "module"in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)from CommonJS instead ofrequire(…). - Stay on the existing version of the package until you can move to ESM.
| /** | |
| * This is ported from Rangy's selection save and restore module and has no dependencies. | |
| * Copyright 2019, Tim Down | |
| * Licensed under the MIT license. | |
| * | |
| * Documentation: https://github.com/timdown/rangy/wiki/Selection-Save-Restore-Module | |
| * Use "rangeSelectionSaveRestore" instead of "rangy" | |
| */ | |
| var rangeSelectionSaveRestore = (function() { | |
| var markerTextChar = "\ufeff"; |
| global.find = re => json => [...find(json, re)] | |
| function* find(v, regex, path = '') { | |
| if (regex.test(path)) { | |
| yield path | |
| return | |
| } | |
| if (typeof v === 'undefined' || v === null) { | |
| return |
| /* | |
| * I've used blessed to create a textbox at the bottom line in the screen. | |
| * The rest of the screen is the 'body' where your code output will be added. | |
| * This way, when you type input, your program won't muddle it with output. | |
| * | |
| * To try this code: | |
| * - $ npm install blessed --save | |
| * - $ node screen.js | |
| * | |
| * Key points here are: |
| # In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env | |
| # variable pointing GPG to the gpg-agent socket. This little script, which must be sourced | |
| # in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start | |
| # gpg-agent or set up the GPG_AGENT_INFO variable if it's already running. | |
| # Add the following to your shell init to set up gpg-agent automatically for every shell | |
| if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then | |
| source ~/.gnupg/.gpg-agent-info | |
| export GPG_AGENT_INFO | |
| else |
npm Users By Downloads (git.io/npm-top)
npm users sorted by the monthly downloads of their modules, for the range May 6, 2018 until Jun 6, 2018.
Metrics are calculated using top-npm-users.
| # | User | Downloads |
|---|
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft,elem.offsetTop,elem.offsetWidth,elem.offsetHeight,elem.offsetParent
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.