Dictionaries.renameKey()

Rename a key in a dictionary and return the result (a new dictionary).

Usage

Hover over inputs/exits for more info.

var Dictionaries = require('machinepack-dictionaries');


// Rename a key in a dictionary and return the result (a new dictionary).

Dictionaries.renameKey({

dictionary: {},

originalKey: 'studentName',

newKey: 'studentFullName',

force: true,

}).execSync();

Inputs

dictionary required

The dictionary to rename the key in.

{}
originalKey required

The key to rename.

'studentName'
newKey required

A new name for the key.

'studentFullName'
force

Whether to overwrite an existing key with the same name if there is a conflict.

true

Exits

error

An unexpected error occurred.

noSuchKey

The specified key does not exist.

keyAlreadyExists

An existing key is already using the specified name for the new key.

success

OK.

(varies based on provided inputs)