Skip to content

Instantly share code, notes, and snippets.

With registered links
  #hasAny
    ✅ is true
  #all
    ✅ is a list of all registered links
Without registered links
  #hasAny
    ✅ is false
 #all
@willmendesneto
willmendesneto / settings.json
Last active October 19, 2022 02:31
VSCode: Settings configuration
{
"workbench.startupEditor": "newUntitledFile",
"workbench.activityBar.visible": false,
"editor.multiCursorModifier": "ctrlCmd",
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/bower_components": true,
"**/.tmp": true,
"**/.DS_Store": true
# Creating folder jumping on the created folder
mkdir multiple-package-versions-in-project && \
cd multiple-package-versions-in-project \
# Starting a NPM project
npm init -y && \
# Installing old & new versions of `feature-toggle-service` package
npm install --save \
  feature-toggle-service@npm:feature-toggle-service@4.0.0 \
 feature-toggle-service-next@npm:feature-toggle-service@6.0.0
@willmendesneto
willmendesneto / index.js
Created July 13, 2021 03:11
Using multiple versions of the same package in a project: index.js
const { isOn, set } = require('feature-toggle-service');
const { isOn: isOnNext, set: setNext } = require('feature-toggle-service-next');
const defaultConfig = { enableFirstSection: true };
set(defaultConfig);
setNext(defaultConfig);
// ❌ Old version: does NOT have a `debug` option
console.log(isOn('enableFirstSection'));
// ✅ Latest version: does have a `debug` option available
@willmendesneto
willmendesneto / package.json
Created July 13, 2021 03:09
Using multiple versions of the same package in a project: package.json
{
"name": "multiple-versions-of-package-in-project",
"version": "1.0.0",
"description": "Using multiple versions of the same package in a project",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "Will Mendes <willmendesneto@gmail.com>",
@willmendesneto
willmendesneto / README.md
Created July 13, 2021 03:06
Using multiple versions of the same package in a project

How to apply that

  1. Install the packages (old and latest versions) adding a specific name/namespace for the latest one
npm install --save \
  feature-toggle-service@npm:feature-toggle-service@4.0.0 \
  feature-toggle-service-next@npm:feature-toggle-service@6.0.0
// Link for example in Typescript playground
// https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAcwKZQMIODZAKAWAChFTEJtcB+ALkQG9iznEBDAB3dVYCdXJUtRAGcoPGGGQBuJi1L8YAW1awEQ0eMkyScxABs4rACYTkAFVQAPKOrGntu8nHA26YEIoBGqHg91QAC1RFQTp6AG0AazoNUwBdOn4ATwBfRAAfRHc9PT9SFOIASjoANzgYIwZZUgowUQYOLl5+CFREAF5EAHI9CVQugBo2MCUVeCROrvYeOGQeVGFhQcRA4LbO7L0hg2NTC2sO7oAZQxNJADpL5YoXQ4BGNM7anGQMzPoU7WqnOrg9VHOBnwjW4fAEQwUylUYCGqxC21OeysUCGNzAUEK2gKRGIoEg0JQ6CwYBeACZCDoapRkEJGJSWCDmgJbJppN9mJCxmoYnYtOyyDszuZkSz7PyqS4hO4vD48iw4aEGFEeayEsNUhksiAcnLscVEGUKlV6bV6oywa1Ds9qOdzS02lQqN1emB+nLTVBhqMCU9qVRbSMoeNEI7utNZvNFl13Qh6gqrX7zvHQ5sY3VPYKkQdfSSbZnJPtPaGuiddhcrmn6mjPTmXv7qyGnXcvibY38AUC8HbwV6gwhYUF4fpEQXkajnOjMcRsbjwNBg2hMNSAMwU5jWmlhcVsTig+2ivn0jmBrlgA9so8CkfC6znuXrieuLUy3zbhW05UiXnINXJNKZVNvj1UpykqOkH3TBpdyZS1JhdfoIRPH0wxmOYFiWAc1kOTYETLG8a2Oa9LnOa5H3uR4fheRsGE+YhvlNdtAVmLtoItVBEO9cZMKHfN8PHFwpyIFIgA
function getConfig(
config?: {
appearance?: string;
animation?: string;
loadingText?: string;
node example.js | pino-sanitize -u=":{UUID}" -h=":{HASH}" -q=":{QUERY-STRING}" -k="err,msg,stack"
'use strict';
const pino = require('pino')();
const uuid = 'fe35c68e-1648-40a5-8f3a-a7d5ae054261';
const hash = '2cccdfbad40b872c6615c9721d14b904465a424e';
pino.info('hello world');
pino.error('this is at error level');
pino.info('the answer is %d', 42);
{
"name": "my-project",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"launchdarkly-node-server-sdk": "^5.14.3"
}
}