Based on:
Version 4 is an ES module and requires Node.js 22.12 or later. CommonJS
consumers on those versions can still load it with a plain require().
The library also runs in browsers: it bundles cleanly with standard
tooling (esbuild, webpack, etc.) and is tested in Chromium, Firefox, and
WebKit.
npm install activitystrea.ms
import as from 'activitystrea.ms'
// Create a simple object
const doc = await as.object()
.name('baz')
.content(
as.langmap()
.set('en', 'bar')
.set('fr', 'foo'))
.publishedNow()
.prettyWrite()Which produces the output:
{
"@context": "https://www.w3.org/ns/activitystreams",
"@type": "Object",
"contentMap": {
"en": "bar",
"fr": "foo"
},
"name": "baz",
"published": "2015-07-17T00:50:09.889Z"
}// Create a simple activity
const doc = await as.create()
.actor('acct:sally@example.org')
.object('http://www.example.org/post')
.prettyWrite()Which produces the output:
{
"@context": "https://www.w3.org/ns/activitystreams",
"@type": "Create",
"actor": "acct:sally@example.org",
"object": "http://www.example.org/post"
}To parse a received Activity Streams 2.0 document, use as.import():
import as from 'activitystrea.ms'
const obj = await as.import({
'@context': 'https://www.w3.org/ns/activitystreams',
type: 'Create',
actor: 'https://social.example/sally',
object: {
type: 'Note',
content: 'Hello, world!'
}
})
console.log(obj.type)
console.log(obj.actor.first.id)
console.log(obj.object.first.content.get())The API uses a fluent factory pattern for creating AS objects. There are
factory methods for each of the main types of objects defined by the Activity
Streams 2.0 vocabulary. Each takes an optional array of types that will be set
on the object. If the [types] is unspecified, a default will be assigned
depending on the object being created. Each of the factory methods returns a
builder specific to the kind of object being generated. Once the object has
been built, call the get method to return the generated object.
as.object([types])as.activity([types])as.collection([types])as.orderedCollection([types])as.collectionPage([types])as.orderedCollectionPage([types])as.link([types])as.accept([types])as.tentativeAccept([types])as.add([types])as.arrive([types])as.create([types])as.delete([types])as.follow([types])as.ignore([types])as.join([types])as.leave([types])as.like([types])as.offer([types])as.invite([types])as.reject([types])as.tentativeReject([types])as.remove([types])as.undo([types])as.update([types])as.view([types])as.listen([types])as.read([types])as.move([types])as.travel([types])as.announce([types])as.block([types])as.flag([types])as.dislike([types])as.application([types])as.group([types])as.person([types])as.organization([types])as.service([types])as.article([types])as.document([types])as.relationship([types])as.profile([types])as.audio([types])as.image([types])as.video([types])as.note([types])as.page([types])as.question([types])as.event([types])as.place([types])as.mention([types])as.tombstone([types])
The object returned by get() is a read-only view of the Activity Stream
object. It will have property methods that are specific to the object's type.
You can export the built object as an ordinary Javascript object using the
export method. This will generate a JSON-LD compliant Javascript object.
import as from 'activitystrea.ms'
const note = as.note()
.name('foo')
.content('this is a simple note')
.get()
console.log(note.name.valueOf())
console.log(note.content.valueOf())
console.log(note.type)import as from 'activitystrea.ms'
const obj = await as.note()
.name('foo')
.content('this is a simple note')
.get()
.export()
// obj is an ordinary javascript object
console.log(obj.type)
console.log(obj.name)
console.log(obj.content)To serialize the Activity Streams object out as JSON, use the write or
prettyWrite methods
import as from 'activitystrea.ms'
const doc = await as.note()
.name('foo')
.content('this is a simple note')
.write()import as from 'activitystrea.ms'
const doc = await as.note()
.name('foo')
.content('this is a simple note')
.prettyWrite()Note that the export, write, and prettyWrite methods are all async and return promises.
This is largely because of the JSON-LD processing that's happening under the covers.
The base module. (CommonJS consumers on Node 22.12+ can use
const as = require('activitystrea.ms') instead.)
Returns a new as.models.Object.Builder instance.
Returns a new as.models.Activity.Builder instance.
Returns a new as.models.Collection.Builder instance.
Returns a new as.models.OrderedCollection.Builder instance.
Returns a new as.models.CollectionPage.Builder instance.
Returns a new as.models.OrderedCollectionPage.Builder instance.
Returns a new as.models.Link.Builder instance.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Accept activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#TentativeAccept activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Add activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Arrive activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Create activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Delete activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Follow activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Ignore activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Join activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Leave activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Like activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Offer activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Invite activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Reject activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#TentativeReject activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Remove activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Undo activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Update activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#View activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Listen activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Read activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Move activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Travel activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Announce activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Block activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Flag activity.
Returns a new as.models.Activity.Builder instance generating an http://www.w3.org/ns/activity#Dislike activity.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Application object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Group object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Person object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Service object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Organization object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Article object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Document object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Audio object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Image object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Video object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Note object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Page object.
Returns a new as.models.Question.Builder instance generating an http://www.w3.org/ns/activity#Question object.
Returns a new as.models.Object.Builder instance generating an http://www.w3.org/ns/activity#Event object.
Returns a new as.models.Relationship.Builder instance generating an http://www.w3.org/ns/activity#Relationship object.
Returns a new as.models.Profile.Builder instance generating an http://www.w3.org/ns/activity#Profile object.
Returns a new as.models.Place.Builder instance generating an http://www.w3.org/ns/activity#Place object.
Returns a new as.models.Link.Builder instance generating an http://www.w3.org/ns/activity#Mention link.
Returns a new as.models.Tombstone.Builder instance generating an
http://www.w3.org/ns/activity#Tombstone object.
Imports the specified JavaScript object obj, performing JSON-LD expansion as necessary. Returns a promise that resolves to the imported as.models.Object.
const obj = {
'@context': 'https://www.w3.org/ns/activitystreams',
type: 'Person',
name: 'Joe'
}
const imp = await as.import(obj)
console.log(imp.type)Registers a JSON-LD context document for offline resolution. When an
imported document's @context includes the registered URL, the local copy
is used instead of fetching it over the network. The AS2 context and
https://w3id.org/security/v1 are pre-registered.
as.registerContext('https://example.com/context', {
'@context': {
ex: 'https://example.com/context#',
bar: 'ex:bar'
}
})Set to a constant value of application/activity+json
as.models.Base is the base class for all objects. It is not intended to be used directly by developers.
expanded- The underlying JSON-LD expanded JavaScript objectbuilder- Aas.model.Base.Buildersubclass
Returns the value of the JSON-LD @id property or underfined.
Returns the value of the JSON-LD @type property. If @type has only a single value, then a single JavaScript string will be returned. If the @type has multiple values, a JavaScript Array will be returned. If the @type is not specified, undefined will be returned.
Returns true if the object has a value for the specified key
Returns the value for the specified key. The return value will vary based on the property being requested. The return value can be a JavaScript primitive, a as.models.Base instance, or an Iterable of JavaScript primitives or as.models.Base instances. Will returned undefined if the no value is specified for the given key
Exports the object by performing a JSON-LD compaction. If export fails, the promise will reject with the error. If the export succeeds, the promise will resolve with the exported JavaScript object.
const obj = as.object().name('Joe').get()
const exp = await obj.export()
console.log(exp.name)
console.log(exp.type)Write the object out to a JSON-LD string. If writing fails, the promise will reject with the error. If the write succeeds, the promise will resolve with the JSON-LD string.
const obj = as.object().name('Joe').get()
const string = await obj.write()
console.log(string)Write the object out to an indented JSON-LD string. If writing fails, the promise will reject with the error. If the write succeeds, the promise will resolve with the JSON-LD string.
const obj = as.object().name('Joe').get()
const string = await obj.prettyWrite()
console.log(string)Returns a new as.models.Base.Builder instance that can be used to modify
this object. Note that model objects memoize property values on first
access, so modify() should only be used on objects that have not been
read from yet.
Returns a function that can be used to create new as.models.Base.Builder instances using this object as a template. The new Builder will be pre-filled with the properties already specified on this object.
const templ = as.like().actor('http://example.org/sally').get().template()
const like1 = await templ().object('http://example.org/1').prettyWrite()
const like2 = await templ().object('http://example.org/2').prettyWrite()The base Builder interface. This is not intended to be used directly by developers. Most of the methods on the Builder instances return a reference back to the Builder itself allowing methods to be chained.
Set the value of the @id property. Calling this repeatedly will overwrite the previous value.
Set a value for the specified key.
const object = as.object()
object.set('foo', 'bar')Returns the constructed as.models.Base instance.
The base class for all Activity Streams 2.0 Object instances. Inherits from as.models.Base
Returns the value of the https://www.w3.org/ns/activitystreams#attachment property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#attributedTo property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#content property. Will be either undefined or a as.models.LanguageValue.
Returns the value of the https://www.w3.org/ns/activitystreams#context property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#name property. Will be either undefined or a as.models.LanguageValue.
Returns the value of the https://www.w3.org/ns/activitystreams#summary property. Will be either undefined or a as.models.LanguageValue.
Returns the value of the https://www.w3.org/ns/activitystreams#endTime property. Will be either undefined or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#published property. Will be either undefined or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#startTime property. Will be either undefined or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#updated property. Will be either undefined or a JavaScript Date object.
Returns the value of the https://www.w3.org/ns/activitystreams#generator property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#icon property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#image property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#inReplyTo property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#location property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#preview property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#replies property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#audience property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#tag property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#url property. Will be either undefined or an Iterable of as.model.Link instances.
Returns the value of the https://www.w3.org/ns/activitystreams#to property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#bto property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#cc property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#bcc property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#duration property. Will be either undefined or a frozen plain object with the same numeric properties as a Temporal.Duration: years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, and nanoseconds. All properties are always present, with 0 for unspecified units. Negative durations have negative values. Malformed duration strings yield undefined.
const doc = await as.import({ type: 'Video', duration: 'PT1H30M' })
console.log(doc.duration.hours) // 1
console.log(doc.duration.minutes) // 30Builder for as.models.Object instances.
Adds a value to the https://www.w3.org/ns/activitystreams#attachment property.
Adds a value to the https://www.w3.org/ns/activitystreams#attributedTo property.
Sets an optional language-tagged value for the https://www.w3.org/ns/activitystreams#content property. To set
language-tagged values, use the as.langmap method to create a
LanguageValue.Builder.
as.object()
.content('simple content')
.get()as.object()
.content(
as.langmap()
.set('default content')
.set('es', 'other content')
)
.get()Adds a value to the https://www.w3.org/ns/activitystreams#context property.
Sets an optional language-tagged value for the https://www.w3.org/ns/activitystreams#name property.
as.object()
.name('simple display name')
.get()as.object()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get()Sets an optional language-tagged value for the https://www.w3.org/ns/activitystreams#summary property.
as.object()
.summary('simple summary')
.get()as.object()
.summary(
as.langmap()
.set('default summary')
.set('es', 'other summary')
)
.get()Sets the value of the https://www.w3.org/ns/activitystreams#endTime property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#endTime property to the current date and time.
Sets the value of the https://www.w3.org/ns/activitystreams#published property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#published property to the current date and time.
Sets the value of the https://www.w3.org/ns/activitystreams#startTime property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#startTime property to the current date and time.
Sets the value of the https://www.w3.org/ns/activitystreams#updated property.
The value must be a JavaScript Date object.
Sets the value of the https://www.w3.org/ns/activitystreams#updated property to the current date and time.
Adds a value to the https://www.w3.org/ns/activitystreams#generator property.
Adds a value to the https://www.w3.org/ns/activitystreams#icon property.
Adds a value to the https://www.w3.org/ns/activitystreams#image property.
Adds a value to the https://www.w3.org/ns/activitystreams#inReplyTo property.
Adds a value to the https://www.w3.org/ns/activitystreams#location property.
Adds a value to the https://www.w3.org/ns/activitystreams#preview property.
Adds a value to the https://www.w3.org/ns/activitystreams#replies property.
Adds a value to the https://www.w3.org/ns/activitystreams#audience property.
Adds a value to the https://www.w3.org/ns/activitystreams#tag property.
Adds a value to the https://www.w3.org/ns/activitystreams#url property.
Adds a value to the https://www.w3.org/ns/activitystreams#to property.
Adds a value to the https://www.w3.org/ns/activitystreams#bto property.
Adds a value to the https://www.w3.org/ns/activitystreams#cc property.
Adds a value to the https://www.w3.org/ns/activitystreams#bcc property.
Sets the value of the https://www.w3.org/ns/activitystreams#duration property.
The value is either a number of seconds or an ISO 8601 duration string
(e.g. 'PT1H30M').
Base class for all Activity Streams 2.0 Activity instances. Inherits from as.models.Object
Returns the value of the https://www.w3.org/ns/activitystreams#actor property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#object property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#target property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#result property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#origin property. Will be either undefined or an Iterable of as.model.Base instances.
Returns the value of the https://www.w3.org/ns/activitystreams#instrument property. Will be either undefined or an Iterable of as.model.Base instances.
The base class for all as.models.Activity builder instances. Inherits from as.models.Object.Builder
Adds a value to the https://www.w3.org/ns/activitystreams#actor property.
Adds a value to the https://www.w3.org/ns/activitystreams#object property.
Adds a value to the https://www.w3.org/ns/activitystreams#target property.
Adds a value to the https://www.w3.org/ns/activitystreams#result property.
Adds a value to the https://www.w3.org/ns/activitystreams#origin property.
Adds a value to the https://www.w3.org/ns/activitystreams#instrument property.
The base class for all Activity Streams 2.0 Collection objects. Inherits from as.models.Object
Returns the value of the https://www.w3.org/ns/activitystreams#totalItems property. The value will either be undefined or a numeric integer greater than or equal to zero.
Returns the value of the https://www.w3.org/ns/activitystreams#current property. The value will either be undefined or a as.models.Base instance.
Returns the value of the https://www.w3.org/ns/activitystreams#last property. The value will either be undefined or a as.models.Base instance.
Returns the value of the https://www.w3.org/ns/activitystreams#first property. The value will either be undefined or a as.models.Base instance.
Returns the value of the https://www.w3.org/ns/activitystreams#items property as an Iterable of as.models.Base instances.
The base class for all as.models.Collection builders. Inherits from as.models.Object.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#totalItems property. The value must be a numeric integer greater than or equal to 0.
Sets the value of the https://www.w3.org/ns/activitystreams#current property. The value must either be a URL string or a as.models.Link instance.
Sets the value of the https://www.w3.org/ns/activitystreams#last property. The value must either be a URL string or a as.models.Link instance.
Sets the value of the https://www.w3.org/ns/activitystreams#first property. The value must either be a URL string or a as.models.Link instance.
Adds a value to the https://www.w3.org/ns/activitystreams#items property.
The base class for all Activity Streams 2.0 OrderedCollection objects. Inherits from as.models.Collection
The base class for all as.models.OrderedCollection builders. Inherits from as.models.Collection.Builder
The base class for all as.models.CollectionPage instances. Inherits from as.models.Collection
Returns the value of the https://www.w3.org/ns/activitystreams#next property. The value will either be undefined or a as.models.Base instance.
Returns the value of the https://www.w3.org/ns/activitystreams#prev property. The value will either be undefined or a as.models.Base instance.
The base class for all as.models.CollectionPage builders. Inherits from as.models.Collection.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#next property. The value must either be a URL string or a as.models.Link instance.
Sets the value of the https://www.w3.org/ns/activitystreams#prev property. The value must either be a URL string or a as.models.Link instance.
The base class for all as.models.OrderedCollectionPage instances. Inherits from both as.models.CollectionPage and as.models.OrderedCollection
Returns the value of the https://www.w3.org/ns/activitystreams#startIndex property. The value will either be undefined or a numeric integer greater than or equal to zero.
Class: as.models.OrderedCollectionPage.Builder > as.models.CollectionPage.Builder, as.models.OrderedCollection.Builder
The base class for all as.models.OrderedCollectionPage builders. Inherits from both as.models.CollectionPage.Builder and as.models.OrderedCollection.Builder.
Sets the value of the https://www.w3.org/ns/activitystreams#startIndex property. The value must be a numeric integer greater than or equal to zero.
The base class for all Activity Streams 2.0 Links. Inherits from as.models.Base
Returns the value of the https://www.w3.org/ns/activitystreams#href property. The value will either be undefined or a URL string.
Returns the value of the https://www.w3.org/ns/activitystreams#rel property. The value will either be undefined or an Iterable of strings.
Returns the value of the https://www.w3.org/ns/activitystreams#mediaType property. The value will either be undefined or a MIME Media Type.
Returns the value of the https://www.w3.org/ns/activitystreams#name property as a LanguageValue.
Returns the value of the https://www.w3.org/ns/activitystreams#hreflang property. The value will either be undefined or a BCP 47 Language Tag.
Returns the value of the https://www.w3.org/ns/activitystreams#height property.The value will either be undefined or a numeric integer greater than or equal to zero.
Returns the value of the https://www.w3.org/ns/activitystreams#width property.The value will either be undefined or a numeric integer greater than or equal to zero.
The base class for all as.models.Link builders. Inherits from as.models.Base.Builder
Specifies the value of the https://www.w3.org/ns/activitystreams#href property. The value must be a URL string.
Adds a value to the https://www.w3.org/ns/activitystreams#rel property;
Sets the value of the https://www.w3.org/ns/activitystreams#mediaType property. The value must be a valid MIME type.
Specifies an optionally language-tagged name.
as.link()
.name('simple display name')
.get()as.link()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get()Sets the value of the https://www.w3.org/ns/activitystreams#hreflang property.
The value must be a BCP 47 Language Tag.
Sets the value of the https://www.w3.org/ns/activitystreams#height property.
The value is a numeric integer greater than or equal to zero.
Sets the value of the https://www.w3.org/ns/activitystreams#width property.
The value is a numeric integer greater than or equal to zero.
The base class for all Activity Streams 2.0 Place objects. Inherits from as.models.Object
Returns the value of the https://www.w3.org/ns/activitystreams#accuracy property. The value will either be undefined or a numeric integer in the range 0 <= n <= 100.
Returns the value of the https://www.w3.org/ns/activitystreams#altitude property. The value will be either undefined or a numeric float.
Returns the value of the https://www.w3.org/ns/activitystreams#latitude property. The value will be either undefined or a numeric float in the range -90.0 <= n <= 90.0.
Returns the value of the https://www.w3.org/ns/activitystreams#longitude property. The value will be either undefined or a numeric float in the range -180.0 <= n <= 180.0.
Returns the value of the https://www.w3.org/ns/activitystreams#radius property.
The value will be either undefined or a numeric float greater than or equal to zero.
Returns the value of the https://www.w3.org/ns/activitystreams#units property. The value will be one of: cm, feet, inches, km, m, miles, or any absolute URI.
The base class for all as.models.Place builders. Inherits from as.models.Object.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#accuracy property.
The value is a numeric integer in the range 0 <= n <= 100
Sets the value of the https://www.w3.org/ns/activitystreams#altitude property. The value is a numeric float.
Sets the value of the https://www.w3.org/ns/activitystreams#latitude property. The value is a numeric float in the range -90.0 <= n <= 90.0.
Sets the value of the https://www.w3.org/ns/activitystreams#longitude property. The value is a numeric float in the range -180.0 <= n <= 180.0.
Sets the value of the https://www.w3.org/ns/activitystreams#radius property. The value is a numeric float greater or equal to 0.0.
Sets the value of the https://www.w3.org/ns/activitystreams#units property.
The value must be one of: cm, feet, inches, km, m, miles, or any absolute URI.
The base class for all Activity Streams 2.0 Profile objects. Inherits from as.models.Object
The base class for all as.models.Profile builders. Inherits from
as.models.Object.Builder
Sets the value of the https://www.w3.org/ns/activitystreams#describes property.
The base class for all Activity Streams 2.0 Question objects. Inherits from
as.models.Activity;
Returns the value of the https://www.w3.org/ns/activitystreams#anyOf property.
The value will either be undefined or an Iterable of as.models.Base objects.
Returns the value of the https://www.w3.org/ns/activitystreams#oneOf property.
The value will either be undefined or an Iterable of as.models.Base objects.
The base class for all as.models.Question builders. Inherits from
as.models.Activity.Builder;
Adds a value to the https://www.w3.org/ns/activitystreams#anyOf property.
Adds a value to the https://www.w3.org/ns/activitystreams#oneOf property.
The base class for all Activity Streams 2.0 Relationship objects. Inherits
from as.models.Object.
Returns the value of the https://www.w3.org/ns/activitystreams#subject property. The value will either be undefined or an as.models.Base object.
Returns the value of the https://www.w3.org/ns/activitystreams#relationship property. The value will either be undefined or an Iterable of as.models.Base objects.
Returns the value of the https://www.w3.org/ns/activitystreams#object property. The value will either be undefined or an Iterable of as.models.Base objects.
The base class for all as.models.Relationship builders. Inherits from as.models.Object.Builder.
Sets the value of the http://ww.w3.org/ns/activitystreams#subject property.
Adds a value to the https://www.w3.org/ns/activitystreams#relationship property.
Adds a value to the https://www.w3.org/ns/activitystreams#object property.
Returns the date and time the object was deleted.
Returns the former type of the object that was deleted.
Sets the date and time the represented object was deleted.
Specifies the former type of the object that was deleted.
Used to encapsulate language tagged properties within an Activity Streams document.
// assuming the default system locale is `en-US`:
const obj = as.object()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get()
const languagevalue = obj.name
console.log(languagevalue.get()) // 'default display name'
console.log(languagevalue.get('es')) // 'other display name'// assuming the default system locale is `es`:
const obj = as.object()
.name(
as.langmap()
.set('default display name')
.set('es', 'other display name')
)
.get()
const languagevalue = obj.name
console.log(languagevalue.get()) // 'other display name'
console.log(languagevalue.get('en-US')) // 'default display name'Language tags are matched case-insensitively, using RFC 4647 lookup with a
prefix-match fallback (asking for en finds an en-US entry, and asking
for en-US-x-foo finds an en-US entry). The default language comes from
the LANG environment variable in Node.js, navigator.language in
browsers, and falls back to en-US.