Skip to content

Instantly share code, notes, and snippets.

View cspence001's full-sized avatar

Ciara Spencer cspence001

  • Richmond, Virginia
View GitHub Profile
@jordanbtucker
jordanbtucker / prompt-for-password.js
Last active November 10, 2023 20:00
Database encryption with NeDB
/**
* This is an example of app that uses an ecrypted NeDB database. It prompts the
* user for a password, decrypts the database, displays any existing records,
* promtps the user for a new record to store, encrypts that record, then exits.
* The password must be given each time the app is started.
*/
const crypto = require('crypto')
const inquirer = require('inquirer')
const scrypt = require('scryptsy')
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;