Class: Name

Name

new Name(components)

Create a new Name from components.
Parameters:
Name Type Description
components string | Name | Array.<(string|Array.<number>|ArrayBuffer|Buffer|Name)> if a string, parse it as a URI. If a Name, add a deep copy of its components. Otherwise it is an array of components which are appended according to Name.append, so convert each and store it as an array of Buffer. If a component is a string, encode as utf8.
Source:

Classes

Component

Methods

(static) createNameArray()

Parse uri as a URI and return an array of Buffer components.
Source:

(static) fromEscapedString(escapedString) → {Blob}

Make a blob value by decoding the escapedString according to NDN URI Scheme. If escapedString is "", "." or ".." then return null, which means to skip the component in the name.
Parameters:
Name Type Description
escapedString string The escaped string to decode.
Source:
Returns:
The unescaped Blob value. If the escapedString is not a valid escaped component, then the Blob isNull().
Type
Blob

(static) fromEscapedStringAsBuffer()

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

(static) getComponentContentDigestValue()

If component is a ContentDigest, return the digest value as a Buffer slice (don't modify!). If not a ContentDigest, return null. A ContentDigest component is Name.ContentDigestPrefix + 32 bytes + Name.ContentDigestSuffix.
Source:

(static) toEscapedString(component) → {string}

Return value as an escaped string according to NDN URI Scheme. We can't use encodeURIComponent because that doesn't encode all the characters we want to.
Parameters:
Name Type Description
component Buffer | Name.Component The value or Name.Component to escape.
Source:
Returns:
The escaped string.
Type
string

add()

Deprecated:
  • Use append.
Source:

addSegment()

Deprecated:
  • Use appendSegment.
Source:

append(component) → {Name}

Convert the component to a Buffer and append to this Name. Return this Name object to allow chaining calls to add.
Parameters:
Name Type Description
component Name.Component | String | Array.<number> | ArrayBuffer | Buffer | Name If a component is a string, encode as utf8 (but don't unescape).
Source:
Returns:
Type
Name

appendSegment(segment) → {Name}

Append 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
Parameters:
Name Type Description
segment number The segment number.
Source:
Returns:
This name so that you can chain calls to append.
Type
Name

appendSegmentOffset(segmentOffset) → {Name}

Append 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
Parameters:
Name Type Description
segmentOffset number The segment byte offset.
Source:
Returns:
This name so that you can chain calls to append.
Type
Name

appendSequenceNumber(sequenceNumber)

Append 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
Parameters:
Name Type Description
sequenceNumber number The sequence number.
Source:
Returns:
This name so that you can chain calls to append.

appendTimestamp(timestamp)

Append 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
Parameters:
Name Type Description
timestamp number The number of microseconds since the UNIX epoch (Thursday, 1 January 1970) not counting leap seconds.
Source:
Returns:
This name so that you can chain calls to append.

appendVersion(version) → {Name}

Append 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.
Parameters:
Name Type Description
version number The version number.
Source:
Returns:
This name so that you can chain calls to append.
Type
Name

clear()

Clear all the components.
Source:

compare(other, iStartComponent, nComponents, {Name, iOtherStartComponent, nOtherComponents) → {boolean|number}

Compare this to the other Name using NDN canonical ordering. If the first components of each name are not equal, this returns -1 if the first comes before the second using the NDN canonical ordering for name components, or 1 if it comes after. If they are equal, this compares the second components of each name, etc. If both names are the same up to the size of the shorter name, this returns -1 if the first name is shorter than the second or 1 if it is longer. For example, std::sort gives: /a/b/d /a/b/cc /c /c/a /bb . This is intuitive because all names with the prefix /a are next to each other. But it may be also be counter-intuitive because /c comes before /bb according to NDN canonical ordering since it is shorter.
Parameters:
Name Type Description
other Name The other Name to compare with.
iStartComponent number The index if the first component of this name to get. If iStartComponent is -N then compare components starting from name.size() - N.
nComponents number The number of components starting at iStartComponent. If greater than the size of this name, compare until the end of the name.
{Name other: The other Name to compare with.
iOtherStartComponent number (optional) The index if the first component of the other name to compare. If iOtherStartComponent is -N then compare components starting from other.size() - N. If omitted, compare starting from index 0.
nOtherComponents number (optional) The number of components starting at iOtherStartComponent. If omitted or greater than the size of this name, compare until the end of the name.
Source:
See:
Returns:
  • 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. The first form of compare is simply compare(other). The second form is compare(iStartComponent, nComponents, other [, iOtherStartComponent] [, nOtherComponents]) which is equivalent to self.getSubName(iStartComponent, nComponents).compare (other.getSubName(iOtherStartComponent, nOtherComponents)) .
    Type
    boolean
  • 0 If they compare equal, -1 if self comes before other in the canonical ordering, or 1 if self comes after other in the canonical ordering.
    Type
    number

cut()

Deprecated:
  • Use getPrefix(-nComponents).
Source:

equals()

Return true if this Name has the same components as name.
Source:

equalsName()

Deprecated:
  • Use equals.
Source:

get(i) → {Name.Component}

Get a Name Component by index number.
Parameters:
Name Type Description
i Number The index of the component, starting from 0. However, if i is negative, return the component at size() - (-i).
Source:
Returns:
Type
Name.Component

getChangeCount() → {number}

Get the change count, which is incremented each time this object is changed.
Source:
Returns:
The change count.
Type
number

getComponent()

Deprecated:
  • To get just the component value array, use get(i).getValue().buf().
Source:

getComponentCount()

Deprecated:
  • Use size().
Source:

getContentDigestValue()

Find the last component in name that has a ContentDigest and return the digest value as Buffer, or null if not found. See Name.getComponentContentDigestValue.
Source:

getName()

Deprecated:
  • Use toUri.
Source:

getPrefix(nComponents) → {Name}

Return a new Name with the first nComponents components of this Name.
Parameters:
Name Type Description
nComponents number The number of prefix components. If nComponents is -N then return the prefix up to name.size() - N. For example getPrefix(-1) returns the name without the final component.
Source:
Returns:
A new name.
Type
Name

getSubName(iStartComponent, (optional)) → {Name}

Get a new name, constructed as a subset of components.
Parameters:
Name Type Description
iStartComponent number The index if the first component to get. If iStartComponent is -N then return return components starting from name.size() - N.
(optional) number nComponents The number of components starting at iStartComponent. If omitted or greater than the size of this name, get until the end of the name.
Source:
Returns:
A new name.
Type
Name

getSuccessor() → {Name}

Get the successor of this name which is defined as follows. N represents the set of NDN Names, and X,Y ∈ N. Operator < is defined by the NDN canonical order on N. Y is the successor of X, if (a) X < Y, and (b) ∄ Z ∈ N s.t. X < Z < Y. In plain words, the successor of a name is the same name, but with its last component advanced to a next possible value. Examples: - The successor of / is /%00 - The successor of /%00%01/%01%02 is /%00%01/%01%03 - The successor of /%00%01/%01%FF is /%00%01/%02%00 - The successor of /%00%01/%FF%FF is /%00%01/%00%00%00
Source:
Returns:
A new name which is the successor of this.
Type
Name

indexOfFileName()

The "file name" in a name is the last component that isn't blank and doesn't start with one of the special marker octets (for version, etc.). Return the index in this.components of the file name, or -1 if not found.
Source:

isPrefixOf(name) → {Boolean}

Return true if the N components of this name are the same as the first N components of the given name.
Parameters:
Name Type Description
name Name The name to check.
Source:
Returns:
true if this matches the given name. This always returns true if this name is empty.
Type
Boolean

match(name) → {Boolean}

Return true if the N components of this name are the same as the first N components of the given name.
Parameters:
Name Type Description
name Name The name to check.
Source:
Returns:
true if this matches the given name. This always returns true if this name is empty.
Type
Boolean

set(uri)

Parse the uri according to the NDN URI Scheme and set the name with the components.
Parameters:
Name Type Description
uri string The URI string.
Source:

size() → {number}

Return the number of name components.
Source:
Returns:
Type
number

to_uri()

Deprecated:
  • Use toUri.
Source:

toUri(includeScheme) → {String}

Return the escaped name string according to NDN URI Scheme.
Parameters:
Name Type Description
includeScheme boolean (optional) If true, include the "ndn:" scheme in the URI, e.g. "ndn:/example/name". If false, just return the path, e.g. "/example/name". If ommitted, then just return the path which is the default case where toUri() is used for display.
Source:
Returns:
Type
String

wireDecode(input, wireFormat)

Decode the input using a particular wire format and update this Name.
Parameters:
Name Type Description
input Blob | Buffer The buffer with the bytes to decode.
wireFormat WireFormat (optional) A WireFormat object used to decode this object. If omitted, use WireFormat.getDefaultWireFormat().
Source:

wireEncode(wireFormat) → {Blob}

Encode this Name for a particular wire format.
Parameters:
Name Type Description
wireFormat WireFormat (optional) A WireFormat object used to encode this object. If omitted, use WireFormat.getDefaultWireFormat().
Source:
Returns:
The encoded buffer in a Blob object.
Type
Blob