Astraia.all

method

Parameters
NameTypeDescription
predFunctionthe predicate to fullfil

A placeholder which all elements of an array are fulfilled by the given predicate.

A.all(A.number)

Astraia.any

method

A placeholder which a value is not null or undefined.

A.any

Astraia.array

method

A placeholder which a value is an array.

A.array

Astraia.equal

method

Parameters
NameTypeDescription
eqvObjectan object to be compared

A placeholder which an object is equal to the given object.
The object is compared by deep comparison.

A.equal({
	"name": "Rin Shibuya",
	"age": 15
})

Astraia.eqv

method

Parameters
NameTypeDescription
eqvObjecta value to be compared

A placeholder which a value is equal to the given value.

A.eqv(765)

Astraia.exists

method

Parameters
NameTypeDescription
predFunctionthe predicate to fillfil

A placeholder which one of the elements of an array is fulfilled by the given predicate.

A.all(A.number)

Astraia.memory

method

Parameters
NameTypeDescription
nameStringthe name

A placeholder which memorize a value.

A.memory("memo")

Astraia.number

method

A placeholder which a value is a number.

A.number

Astraia.object

method

A placeholder which a value is an object and is not an array.

A.object

Astraia.range

method

Parameters
NameTypeDescription
minimumNumberminimum of range
maximumNumbermaximum of range

A placeholder which a value is in the given range.

A.range(346, 765)

Astraia.refer

method

Parameters
NameTypeDescription
nameStringthe name

A placeholder which a value is equals to the memorized value.
The object is compared by deep comparison.

A.refer("memo")

Astraia.regex

method

Parameters
NameTypeDescription
regexRegexa value to be compared

A placeholder which a value is matched to the given regex.

A.regex(/765|346|283/)

Astraia.scan

method

Parameters
NameTypeDescription
rulesObjectrules to replace
sourceObjectan object to replace
Return
TypeDescription
Objecta replaced object by the rules

scans and replaces the object by the given rule.

var rules = [{
	pattern: {
	  "type": A.eqv("add"),
	  "left": A.number,
	  "right": A.number
	},
	action: function(obj) {
	  return obj.left + obj.right;
	}
}, {
	pattern: {
	  "type": A.eqv("sub"),
	  "left": A.number,
	  "right": A.number
	},
	action: function(obj) {
	  return obj.left - obj.right;
	}
}];

// outputs 2
A.scan(rules, {
	"type": "add",
	"left": {
	  "type": "add",
	  "left": 1,
	  "right": 2
	},
	"right": {
	  "type": "sub",
	  "left": 3,
	  "right": 4
	}
});

Astraia.string

method

A placeholder which a value is a string.

A.string