Other core-functions

All other core-functions are statically bound to "core" -namespace.

assert($test) <JSON>

Assert takes the argument $test which is a predicate-expression. Assert is used to check that certain points in the query work as expected. If the assert is satisfied, then the current-value is passed through unchanged. If assert is not satisfied then an error is thrown.

NOTE: Assert is used internally by Operon when writing tests for components.

Example

durationToMillis() <Number>

DurationToMillis takes input object, shaped as {millis, seconds, minutes, hours, days} or {ms, s, min, h, d}, or keys starting with: {mil, s, min, h, d} (Operon will first map to default shape), each having a numeric value if given. Each key is optional. If no keys are given, then duration will be 0.

Example

wait($millis) <JSON>

Wait is used to delay the flow-execution by a given amount of milliseconds in $millis-argument. Wait passes the input-value through unchanged.

Example

mappableTo($value) <Boolean>

MappableTo checks if the input-Object is fully mappable to the given Object-argument in $value. MappableTo returns true if objects are fully mappable, otherwise false. Being fully mappable means that the following conditions are satisfied:

  • All of the $value -object's fields are found from the input-object. Input-object might have extra-fields.
  • Each of the input-object's fields satisfies the $value-object's restrictions for the corresponding field, if restriction was given.
MappableTo is used internally by Operon when the named Object-value is used from Value-statement as restriction.

Example

Example

Example

uuid() <String>

Uuid generates an unique String-identifier with the following pattern: [a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}

Example

next() <JSON>

Next returns the next-value for the value that is sourced from an Array or Object. If input is a value from an Array, then the next value is the next value from the Array. If input is a value from an Object, then the next value is the next value from the Object.

Example

previous() <JSON>

Previous returns the previous-value for the value that is sourced from an Array or Object. If input is a value from an Array, then the previous value is the previous value from the Array. If input is a value from an Object, then the previous value is the previous value from the Object.

Example

parent() <Object Or Array>

Parent returns the value that is parent of the input-value. Input-value must be sourced from an Array or Object to have the parent-link.

NOTE: another way to access the parent is to use the "_" -syntax. For example "$value.x._", means that we are accessing the parent of the field "x".

Example

Example

pos() <Number>

Pos returns the position of the input-value that is sourced from an Array or Object.

NOTE: when value is obtained by filtering an object, then the value is an object itself, and position is always 1.

Example

Example

Example

Example

Example

Example

root() <Object Or Array>

Root returns the value that is the top-level of the input-value that is sourced from an Array or Object. Root works by traversing parent-relations until no parent is found.

NOTE: another way to access the root is to use the "_$" -syntax. For example "$value.x._$", means that we are accessing the root of the field "x".

Example

Example

type() <String>

Type returns the Operon type-name of the input-value as a String. Operon has the following types: Boolean, True, False, Empty, Number, String, Null, Array, Object, Binary, Stream, Path

NOTE: Operon has also the shortcut for type-checking. It works by just typing the typename in the query, and Operon will expand it with "=> type() = typename", which will return a Boolean-value. This can be used as a shortcut when defining type-based restrictions.

Example

Example

Example

spliceLeft($until) <Array Or Object Or String>

SpliceLeft returns the values from an input-value (Array, Object or String) until the $until-argument. The result value is of the same type as the input-value.

For an Array-input the result contains values from position 1 until the position given in the argument $until.

For an Object-input the result contains key-pair -values from position 1until the position given in the argument $until.

For a String-input the result contains String starting from character at index 1, until index given in the argument $until.

For negative $until value, the until-position is calculated starting from the end of the iterable input-value.

Example

Example

Example

spliceRight($start) <Array Or Object Or String>

SpliceRight returns the values from an input-value (Array, Object or String) starting from the $start-argument. The result value is of the same type as the input-value.

For an Array-input the result contains values from position $start until the end of the Array.

For an Object-input the result contains key-pair -values from position $start until the end of the Object.

For a String-input the result contains String starting from character at index $start, until the end of the String.

For negative $start value, the start-position is calculated starting from the end of the iterable input-value.

Example

Example

Example

spliceRange($start, $count) <Array Or Object Or String>

SpliceRange returns the values from an input-value (Array, Object or String) starting from the $start-argument and including in the result the $count amount of items. The result value is of the same type as the input-value.

For an Array-input the result contains values from position $start until the $count amount of items has been included.

For an Object-input the result contains key-pair -values from position $start until the $count amount of items has been included.

For a String-input the result contains String starting from character at index $start, until the $count amount of characters has been included.

For negative $start value, the start-position is calculated starting from the end of the iterable input-value.

For negative $count value, the spliceRange includes the items going towards the left.

Example

Example

Example

Example

stop() <ANY>

Calling stop-function will stop the flow for the current data-frame. The current-value is returned as a result.

Example

update($value, $target) <Array Or Object>

update can be used to update either Array or Object. The difference to object:update or array:update is that core:update can also take the Path as $target. If no $target is given, then all items are updated.

Example

Note: operon has also the Update-pattern, which works with the Paths. When written by using the Update, the above example would be equal to:

$:[
  {bin: 7, bai: 77, baa: 777}	
]: << ~[1].bin: 100;

organize($options <Object>) <Array>

organize tries to create structure for unstructured raw-data (Binary) or String.

Options

  • multiLine : Boolean. Default: not set. Automatically set when not set. When multiLine is set, then the result is an Array of Arrays. When not set, then the result is an Array of Strings.
  • skipFirstLine : Boolean. Default: false.
  • sparseResults : Boolean. Default: true. When true, then the empty-parts are included as empty strings, otherwise they will be omitted from the result.
  • trim : Boolean. Default: true. When set, then the each String is trimmed.
  • parseQuotedStrings : Boolean. Default: true.
  • lineSeparator : String. Default : "\n".
  • separators : String. Default: ";\t".
  • includeLinesStartingWith: Array of String. Default: not set.
  • charset: String. Default: "utf-8". Character encoding scheme for read data.

Example

Example

In this example we use the earthquake-data from USGS, and select the data-rows which has magnitude greater than 5 (richter).

collect($regex) <Array>

collect can be used to apply $regex <String> for the given input Raw or String, and the matching parts are collected into the result Array.

Example

Example