# activity-streams

> A simple tool to facilitate handling and referencing activity streams without unnecessary verbosity

Latest version **4.3.8** (published 2021-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install activity-streams
pnpm add activity-streams
yarn add activity-streams
bun add activity-streams
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.3.8 |
| Published | 2021-09-02 |
| First published | 2014-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 394 |
| Author | Nick Jennings |
| Maintainers | silverbucket |
| Keywords | activity, streams, json-ld, activity-streams |

## Links

- npm: https://www.npmjs.com/package/activity-streams
- Repository: https://github.com/sockethub/sockethub
- Homepage: https://github.com/sockethub/sockethub/tree/master/packages/activity-streams.js
- Issues: https://github.com/sockethub/sockethub/issues
- npm.io page: https://npm.io/package/activity-streams

## Dependencies (1)

- [event-emitter](https://npm.io/package/event-emitter.md) ^0.3.5

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 4.3.8 (latest) — 2021-09-02
- 4.4.0-alpha.0 — 2022-03-04
- 4.3.7 — 2021-05-22
- 4.3.6 — 2021-05-20
- 4.3.5 — 2021-02-22
- 4.3.3 — 2020-12-26
- 4.3.2 — 2020-02-13
- 4.3.1 — 2020-02-13
- 4.3.1-alpha.1 — 2020-02-06
- 4.3.1-alpha.0 — 2020-02-06
- 4.3.0 — 2019-11-25
- 4.2.0 — 2019-09-26
- 4.1.0 — 2018-10-11
- 4.0.0 — 2018-10-11
- 3.1.1 — 2018-10-11
- … 30 more at https://npm.io/package/activity-streams/versions

## README

# activity-streams.js

[![License](https://img.shields.io/npm/l/activity-streams.svg?style=flat)](https://npmjs.org/package/activity-streams)
[![Downloads](http://img.shields.io/npm/dm/activity-streams.svg?style=flat)](https://npmjs.org/package/activity-streams)

A simple tool to facilitate handling and referencing activity streams and it's objects, cutting down on verbosity.

Designed to run in both `node.js` and the `browser`.

I am learning about JSON-LD and ActivityStreams2 as I write this library, so suggestions for improvement are very welcome.

## Install

### Node.js

`$ npm install activity-streams`

```javascript
const ASFactory = require('activity-streams');
const ActivityStreams = ASFactory({
  failOnUnkownObjectProperties: false // default
});
```

### Browser

`<script src="http://example.com/activity-streams.js"></script>`

Once included in a web-page, the `ActivityStreams` base object should be on the global scope, with the sub-properties `ActivityStreams.Object` and `ActivityStreams.Stream`.


## Example

```javascript

const ActivityStreams = ASFactory();

ActivityStreams.Object.create({
  '@id': 'irc://exampleUser@irc.freenode.net',
  '@type': "person",
  displayName: 'Example User',
  url: "http://activitystrea.ms",
  image: {
    url: "http://activitystrea.ms/avatar.jpg",
    mediaType: "image/jpeg",
    width: 250,
    height: 250
  }
});

ActivityStreams.on('activity-object-create', function (obj) {
  console.log('this object was just created: ', obj);
});

ActivityStreams.Object.create({
  '@id': 'irc://irc.freenode.net/activitystreams',
  '@type': "chatroom",
  displayName: '#activitystreams'
});

const exampleUser = ActivityStreams.Object.get('irc://exampleUser@irc.freenode.net');
    // ... returns:
    //  {
    //    '@id': 'irc://exampleUser@irc.freenode.net',
    //    '@type': "person",
    //    displayName: 'Example User',
    //    url: "http://activitystrea.ms",
    //    image: {
    //      url: "http://activitystrea.ms/avatar.jpg",
    //      mediaType: "image/jpeg",
    //      width: 250,
    //      height: 250
    //    }
    //  }

ActivityStreams.Stream({
  '@context': 'send',
  actor: 'irc://exampleUser@irc.freenode.net',
  object: {
    '@type': "message",
    content: "hello world!"
  },
  target: 'irc://irc.freenode.net/activitystreams'
});
    // ... returns:
    //  {
    //    '@context': 'send',
    //    actor: {
    //      '@id': 'irc://exampleUser@irc.freenode.net',
    //      '@type': "person",
    //      displayName: 'Example User',
    //      url: "http://activitystrea.ms",
    //      image: {
    //        url: "http://activitystrea.ms/avatar.jpg",
    //        mediaType: "image/jpeg",
    //        width: 250,
    //        height: 250
    //      }
    //    },
    //    object: {
    //      '@type': "message",
    //      content: "hello world!"
    //    },
    //    target: {
    //      '@id': 'irc://irc.freenode.net/activitystreams',
    //      '@type': "chatroom",
    //      displayName: '#activitystreams'
    //    }
    //  }
```

---
_Source: https://npm.io/package/activity-streams · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
