propetty path utils
import { getAttribute, expand } from "pacc";
const result = getAttribute({ a: [0,{ b: 4 }]}, "a[1].b");
// result === 4
const result = expand("${a + 1}",{ current: { a: 2 }});
// result === 3benchmark avg (min … max) p75 / p99 (min … top 1%)
"[n<5].l" 1.17 µs/iter 1.67 µs █ (833.64 ns … 2.47 µs) 2.42 µs █ (281.78 b … 3.28 kb) 3.01 kb █▇▂▁▃▂▁▁▁▁▁▃▂▄▄▂▂▁▁▂▁ 4.72 ipc ( 2.55% stalls) 98.55% L1 data cache 3.75k cycles 17.68k instructions 39.84% retired LD/ST ( 7.04k)
parse a.b.c.d.e.f.g.h.i.j.k.l.m.n 2.96 µs/iter 3.25 µs ▂█▂ ▅ (2.60 µs … 3.44 µs) 3.41 µs ███▅▅ ▅█▂▂▂▂ ( 6.10 kb … 6.11 kb) 6.10 kb █████▄▁▁▁▁▁▁▄▄▁██████ 5.09 ipc ( 2.02% stalls) 99.10% L1 data cache 9.40k cycles 47.87k instructions 40.50% retired LD/ST ( 19.38k)
parseOnly a.b.c.d.e.f.g.h.i.j.k.l.m.n 2.51 µs/iter 2.85 µs █ (2.18 µs … 3.36 µs) 3.35 µs █▆ ( 4.54 kb … 5.43 kb) 5.41 kb ██▄▄▂▁▁▁▁▃▂█▇█▂▁▂▁▂▁▂ 5.12 ipc ( 2.18% stalls) 98.98% L1 data cache 8.05k cycles 41.20k instructions 40.73% retired LD/ST ( 16.78k)
tokens a.b.c.d.e.f.g.h.i.j.k.l.m.n 1.66 µs/iter 1.68 µs ▆ █▄ ▃ (1.61 µs … 1.75 µs) 1.74 µs ▅█▄██▄ █▂ ▂▅ ( 4.41 kb … 4.42 kb) 4.41 kb ██████▅▁██▃▅▃▆▆██▃▃▁▆ 5.67 ipc ( 2.53% stalls) 99.12% L1 data cache 5.32k cycles 30.18k instructions 40.68% retired LD/ST ( 12.27k)
tokens "abc" " " "abcdefghijklmnopqrstuvwxyz" 1.23 µs/iter 1.12 µs █ (1.02 µs … 2.23 µs) 1.85 µs █▆ ( 2.52 kb … 4.17 kb) 3.43 kb ███▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▇▄▃ 6.02 ipc ( 2.26% stalls) 99.24% L1 data cache 3.94k cycles 23.72k instructions 39.67% retired LD/ST ( 9.41k)
- AST
- prepareAttributesDefinitions
- mergeAttributeDefinitions
- attributeIterator
- extendingAttributeIterator
- parseBytes
- AttributeDefinition
- default_attribute
- default_attribute_writable
- default_collection_attribute
- default_collection_attribute_writable
- string_attribute
- string_attribute_writable
- string_collection_attribute
- string_collection_attribute_writable
- string_set_attribute
- string_set_attribute_writable
- name_attribute
- name_attribute_writable
- email_attribute
- version_attribute
- version_attribute_writable
- description_attribute
- type_attribute
- type_attribute_writable
- state_attribute_writable
- boolean_attribute
- boolean_attribute_writable
- boolean_attribute_writable_true
- boolean_attribute_writable_true
- boolean_attribute_writable_false
- boolean_attribute_false
- yesno_attribute
- empty_attribute
- uuid_attribute
- secret_attribute
- secret_attribute
- secret_attribute_writable
- username_attribute
- password_attribute
- token_attribute
- private_key_attribute
- public_key_attribute
- number_attribute
- number_attribute_writable
- integer_attribute
- integer_attribute
- integer_attribute_writable
- integer_attribute_writable
- size_attribute
- object_attribute
- url_attribute
- url_attribute_writable
- hostname_attribute
- port_attribute
- port_attribute_writable
- id_attribute
- body_attribute_writable
- title_attribute_writable
- priority_attribute
- priority_attribute
- duration_attribute
- duration_attribute_writable
- duration_ms_attribute
- timeout_attribute
- language_attribute
- environmentValues
- expandContextDefault
- expandContextDoubbleCurly
- expand
- promises
- filter
- setAttributes
- getAttributes
- getAttributesJSON
- tokens
- tokens
- setAttribute
- getAttribute
- getAttributeAndOperator
- parseDuration
- formatDuration
- formatDurationISO
- lookup
- Token
- registerToken
- createToken
- PLUS
- MINUS
- STAR
- DIVIDE
- NOT
- NOT_EQUAL
- EQUAL
- GREATER
- GREATER_EQUAL
- LESS
- LESS_EQUAL
- OPEN_ROUND
- CLOSE_ROUND
- OPEN_BRACKET
- CLOSE_BRACKET
- OPEN_CURLY
- CLOSE_CURLY
- QUESTION
- COLON
- SEMICOLON
- COMMA
- DOT
- AMPERSAND
- DOUBLE_AMPERSAND
- BAR
- DOUBLE_BAR
- IDENTIFIER
- STRING
- NUMBER
- BOOLEAN
- EOF
- Type
- raiseOnUnknownType
Type: Object
evalFunction?
Create attributes from its definition.
Returns Object attributes
Merge attribute definitions.
destObject attribute definitions to be used also the merge targetattsObject? attribute definitions to be used
Returns Object merged definitions (dest)
Iterate over attributes.
Returns Iterable<[Array<string>, object]>
Iterate over all attributes of a type.
Returns Iterable<[Array<string>, object]>
Convert byte size formatted string into number of bytes.
Returns number number of total bytes
Type: Object
namestringtypeTypekeyboolean are we an identifying attributewritableboolean can this attribute be modifiedmandatorybooleancollectionboolean are we a collection (set, map, array, object)privateboolean? should the value be showncredentialboolean? any type of credentialpersistentboolean? should we be stored (especially critical for credentials)backpointerAttributeDefinition?constructorFunction? (collection) constructordependsstring? name of an attribute we depend ondescriptionstring? human readabledefaultany? the default valuesetFunction? set the valuegetFunction? get the value can be used to calculate default valuestoInternalFunction?toExternalFunction?asMapEntryFunction? deliver key and value for Map insertionexternalNamestring? attribute name used by external systemvaluesSet<any>? allowed valuesenv(Array<string> | string)? environment variable(s) used to provide the valueadditionalValuesobject? other values to be set in case our attribute is setseparatorstring? separator for collections
Common attribute properties.
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
The description of the object content.
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Unique id within.
Type: AttributeDefinition
The body text.
Type: AttributeDefinition
The one line description.
Type: AttributeDefinition
In case there are several providers able to support a given source which one sould be used ? this defines the order.
Type: AttributeDefinition
Type: AttributeDefinition
Duration in seconds.
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Type: AttributeDefinition
Extract values from environment.
envObject as from process.envattributesObject as from process.envinstanceIdentifierstring part of variable name.
Returns (Object | undefined) undefined if no suitable environment variables have been found
Default expand context using '§{' and '}' as lead in/out
Expand context with doubble curly separaion '{{' '}}'
Expand expressions inside of object graphs.
-
objectany -
contextObject
Returns (any | Promise<any>)
Generate filter function.
filterByObject?
Returns Function
Copies attribute values from a source object into a destination object.
objectObject target object to be modifiedsourceObject origin of the data to be copieddefinitionsObject attribute definitions to be usedcbfunction? callback to be executed for each copied value
Retrive attribute values from an object.
Returns Object values
Retrive attribute values from an object.
Returns Object values
Split expression path into tokens.
Set object attribute. The name may be a property path like 'a.b.c'.
Deliver attribute value. The name may be a property path like 'a.b.c' or a[2]
Returns any value associated with the given property name
Deliver attribute value and operator. The name may be a property path like 'a.b.c <='.
Returns [any, Token] value associated with the given property name
Convert duration formatted string into number of seconds.
Returns number seconds
secondsnumber
Returns string formatted duration
secondsnumber
Returns string formatted duration
Token lookup
Type: Object
tokenToken
strstringprecedencenumber? (optional, default0)typestring?ledFunction? (optional, default(parser,node)=>node)nud(optional, defaultparser=>this)
Returns Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Token
Type: Object
namestringprimitiveboolean?extendsType?membersSet<Type>?clazzFunction?toInternalFunction?toExternalFunction?
Throw if type is not known.
Returns Type
With npm do:
npm install paccBSD-2-Clause