Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

haraka-notes

haraka13.1kMIT1.1.1

Haraka Notes

haraka, notes

readme

Build Status Code Climate Code Coverage

haraka-notes

Notes are objects that exist on Haraka connections and transactions. Prior to the release of haraka-notes, notes was just an empty object. Now notes is an empty object with two functions:

Usage

const Notes = require('haraka-notes')
const myNote = new Notes()

myNote.set('some.path', 'a value') // { some: {path: 'a value'}}
myNote.get('some.path') // 'a value'

set (path, value, [onlyIfUndefined])

Sets a note at a dot delimited path to the specified value. The path can be any number of levels deep and any missing objects in the path are autovivified. Perl afficianados, contain yourselves.

set default

If the third set argument is any truthy value, then the property is only set if the current value is undefined. This is useful for applying default values.

connection.transaction.notes.set('queue.wants', 'smtp_forward')

The above command sets connection.transaction.notes.queue.wants to the value 'smtp_forward'.

get (path)

Fetches the value of a note from a given dot delimited path.

connection.transaction.notes.get('queue.wants')

Array Syntax

The get and set functions support passing the path as an array of strings. This might be useful to the type of masochist that has dots in their JS/JSON keys. Example:

connection.transaction.notes.get(['i.do', 'like', 'pa.in'])

Note Path Registry

To reduce the likelihood of namespace collisions in Haraka notes, consider registering the note paths your plugins use in the registry.

changelog

Changelog

The format is based on Keep a Changelog.

Unreleased

1.1.1 - 2025-01-13

  • dep(eslint): upgrade to v9

1.1.0 - 2024-05-03

  • set: added 'default' mode. See docs. #

1.0.7 - 2024-04-08

  • use [files] in package.json. Delete .npmignore.
  • doc: Changes -> CHANGELOG
  • ci: more shared workflows
  • lint: remove duplicate / stale rules from .eslintrc

1.0.6 - 2022-05-27

  • chore(ci): depend on shared GHA workflows

1.0.5 - 2022-01-26

  • feat: make it possible to set a false value
  • chore(ci): bump lowest node.js version to 14

1.0.4 - 2021-02-04

  • CI: replace Travis & AppVeyor with GitHub actions
  • CI: automatically publish upon release.

1.0.3 - 2020-03-23

  • bump packaging versions
  • remove package-lock.json
  • codeclimate: moved functions out of constructor

1.0.2 - 2017-09-07

  • if an object is passed in, populate the notes with it

1.0.1 - 2017-09-04

  • initial release