Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.
Cedric Poon edited this page Jan 21, 2020 · 2 revisions

Overview

Modify is a mutable class to modify given JSON Object according to its object methods. This class is used in Rjson.modify()

Each object methods will return same (i.e. this) instance of Modify Object.

API

Instantiation

modify(sourceObj)

Each instantiation should be carried out using ordinary function call.

Parameter Type Description Default Required
sourceObj Object Object to be modified Yes

Object Attribute

.self

Raw underlying object.

Accessibility
Getter Yes
Setter No

Object Method

.append(o)

Append object o at the end of all keys with its children keypairs.

Parameter Type Description Default Required
o Object Object to be appended Yes
Return Type Description
* Modify Mutable self reference (i.e. this)

Example

const { Rjson } = require('reyaml-core');
const rj = new Rjson({ foo: 'bar' });

rj.modify(m => m
    .append({ reyaml: 'core' })
);
// or
rj.modify(m => { return m
    .append({ reyaml: 'core' })
});

.prepend(o)

Prepend object o at the beginning of all keys with its children keypairs.

Parameter Type Description Default Required
o Object Object to be prepended Yes
Return Type Description
* Modify Mutable self reference (i.e. this)

Example

const { Rjson } = require('reyaml-core');
const rj = new Rjson({ foo: 'bar' });

rj.modify(m => m
    .prepend({ reyaml: 'core' })
);
// or
rj.modify(m => { return m
    .prepend({ reyaml: 'core' })
});
Clone this wiki locally