Class: Component

Name. Component

new Component(value)

Create a new Name.Component with a copy of the given value.
Parameters:
Name Type Description
value Name.Component | String | Array.<number> | ArrayBuffer | Buffer If the value is a string, encode it as utf8 (but don't unescape).
Source:

Methods

(static) compareBuffers(component1, component2) → {number}

Do the work of Name.Component.compare to compare the component buffers.
Parameters:
Name Type Description
component1 Buffer
component2 Buffer
Source:
Returns:
0 if they compare equal, -1 if component1 comes before component2 in the canonical ordering, or 1 if component1 comes after component2 in the canonical ordering.
Type
number

(static) fromNumber(number) → {Name.Component}

Create a component whose value is the nonNegativeInteger encoding of the number.
Parameters:
Name Type Description
number number
Source:
Returns:
Type
Name.Component

(static) fromNumberWithMarker(number, marker) → {Name.Component}

Create a component whose value is the marker appended with the nonNegativeInteger encoding of the number.
Parameters:
Name Type Description
number number
marker number
Source:
Returns:
Type
Name.Component

(static) fromSegment()

Create a component with the encoded segment number according to NDN naming conventions for "Segment number" (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf param {number} segment The segment number. returns {Name.Component} The new Component.
Source:

(static) fromSegmentOffset()

Create a component with the encoded segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf param {number} segmentOffset The segment byte offset. returns {Name.Component} The new Component.
Source:

(static) fromSequenceNumber()

Create a component with the encoded sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf param {number} sequenceNumber The sequence number. returns {Name.Component} The new Component.
Source:

(static) fromTimestamp()

Create a component with the encoded timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf param {number} timestamp The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds. returns {Name.Component} The new Component.
Source:

(static) fromVersion()

Create a component with the encoded version number according to NDN naming conventions for "Versioning" (marker 0xFD). http://named-data.net/doc/tech-memos/naming-conventions.pdf Note that this encodes the exact value of version without converting from a time representation. param {number} version The version number. returns {Name.Component} The new Component.
Source:

compare(other) → {number}

Compare this to the other Component using NDN canonical ordering.
Parameters:
Name Type Description
other Name.Component The other Component to compare with.
Source:
See:
Returns:
0 if they compare equal, -1 if this comes before other in the canonical ordering, or 1 if this comes after other in the canonical ordering.
Type
number

equals(other) → {Boolean}

Check if this is the same component as other.
Parameters:
Name Type Description
other Name.Component The other Component to compare with.
Source:
Returns:
true if the components are equal, otherwise false.
Type
Boolean

getSuccessor() → {Name.Component}

Get the successor of this component, as described in Name.getSuccessor.
Source:
Returns:
A new Name.Component which is the successor of this.
Type
Name.Component

getValue() → {Blob}

Get the component value.
Source:
Returns:
The component value.
Type
Blob

getValueAsBuffer()

Deprecated:
  • Use getValue. This method returns a Buffer which is the former behavior of getValue, and should only be used while updating your code.
Source:

isSegment() → {number}

Check if this component is a segment number according to NDN naming conventions for "Segment number" (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Returns:
True if this is a segment number.
Type
number

isSegmentOffset()

Check if this component is a segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Returns:
True if this is a segment byte offset.

isSequenceNumber()

Check if this component is a sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Returns:
True if this is a sequence number.

isTimestamp()

Check if this component is a timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Returns:
True if this is a timestamp.

isVersion() → {number}

Check if this component is a version number according to NDN naming conventions for "Versioning" (marker 0xFD). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Returns:
True if this is a version number.
Type
number

toEscapedString() → {string}

Convert this component value to a string by escaping characters according to the NDN URI Scheme. This also adds "..." to a value with zero or more ".".
Source:
Returns:
The escaped string.
Type
string

toNumber() → {number}

Interpret this name component as a network-ordered number and return an integer.
Source:
Returns:
The integer number.
Type
number

toNumberWithMarker(marker) → {number}

Interpret this name component as a network-ordered number with a marker and return an integer.
Parameters:
Name Type Description
marker number The required first byte of the component.
Source:
Throws:
Error If the first byte of the component does not equal the marker.
Returns:
The integer number.
Type
number

toSegment() → {number}

Interpret this name component as a segment number according to NDN naming conventions for "Segment number" (marker 0x00). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Throws:
Error If the first byte of the component is not the expected marker.
Returns:
The integer segment number.
Type
number

toSegmentOffset()

Interpret this name component as a segment byte offset according to NDN naming conventions for segment "Byte offset" (marker 0xFB). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Throws:
Error If the first byte of the component is not the expected marker.
Returns:
The integer segment byte offset.

toSequenceNumber()

Interpret this name component as a sequence number according to NDN naming conventions for "Sequencing" (marker 0xFE). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Throws:
Error If the first byte of the component is not the expected marker.
Returns:
The integer sequence number.

toTimestamp()

Interpret this name component as a timestamp according to NDN naming conventions for "Timestamp" (marker 0xFC). http://named-data.net/doc/tech-memos/naming-conventions.pdf
Source:
Throws:
Error If the first byte of the component is not the expected marker.
Returns:
The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds.

toVersion() → {number}

Interpret this name component as a version number according to NDN naming conventions for "Versioning" (marker 0xFD). Note that this returns the exact number from the component without converting it to a time representation.
Source:
Throws:
Error If the first byte of the component is not the expected marker.
Returns:
The integer version number.
Type
number