@yoda/property

A property is an abstraction that can be used to represent a mutable value that is held in a host object.

var prop = require('@yoda/property');
prop.get('ro.boot.serialno');
prop.set('foobar', 'testkey');

The property key has 3 schemas for different purposes:

  • persistent key: the key starts with persist., these key and values are stored in persistent.
  • readonly key: the key starts with ro.*, these key and values are readonly.
  • normal key: otherwise are read and write, but in-memory.

Methods

(inner) get(key, flagopt) → {String|Number}

Parameters:
Name Type Attributes Description
key string

the property key.

flag string <optional>

the flag for set operation, available values are: persistent and readonly.

Throws:
  • key must be a string.

    Type
    TypeError
  • key must not be empty string.

    Type
    TypeError
Returns:
Type:
string | number

returns the value by the given key.

(inner) set(key, val, flagopt)

Parameters:
Name Type Attributes Description
key string

the property key.

val string

the property val to set.

flag string <optional>

the flag for set operation, available values are: persistent and readonly.

Throws:
  • key must be a string.

    Type
    TypeError
  • key must not be empty string.

    Type
    TypeError
  • value must be required to be not undefined or null.

    Type
    TypeError