# immutable-ics

> Immutable iCalendar document creation

Latest version **0.4.0** (published 2017-08-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install immutable-ics
pnpm add immutable-ics
yarn add immutable-ics
bun add immutable-ics
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2017-08-27 |
| First published | 2016-07-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Angelo Ashmore |
| Maintainers | angeloashmore |
| Keywords | ics, calendar, ical, immutable |

## Links

- npm: https://www.npmjs.com/package/immutable-ics
- Repository: https://github.com/angeloashmore/immutable-ics
- Homepage: https://github.com/angeloashmore/immutable-ics#readme
- Issues: https://github.com/angeloashmore/immutable-ics/issues
- npm.io page: https://npm.io/package/immutable-ics

## Dependencies (6)

- [lodash.isdate](https://npm.io/package/lodash.isdate.md) ^4.0.1
- [lodash.isnull](https://npm.io/package/lodash.isnull.md) ^3.0.0
- [lodash.padstart](https://npm.io/package/lodash.padstart.md) ^4.6.1
- [typed-immutable](https://npm.io/package/typed-immutable.md) 0.0.8
- [lodash.isfunction](https://npm.io/package/lodash.isfunction.md) ^3.0.8
- [lodash.isundefined](https://npm.io/package/lodash.isundefined.md) ^3.0.1

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 0.4.0 (latest) — 2017-08-27
- 0.3.0 — 2017-08-27
- 0.2.5 — 2016-09-08
- 0.2.4 — 2016-07-25
- 0.2.3 — 2016-07-25
- 0.2.2 — 2016-07-25
- 0.2.1 — 2016-07-25
- 0.2.0 — 2016-07-20
- 0.1.0 — 2016-07-18
- 0.0.1 — 2016-07-07

## README

# immutable-ics

Immutable iCalendar document creation using [typed-immutable][0] and
[Immutable.js][1].

## Status

[![npm version](https://badge.fury.io/js/immutable-ics.svg)](http://badge.fury.io/js/immutable-ics)
[![Build Status](https://secure.travis-ci.org/angeloashmore/immutable-ics.svg?branch=master)](http://travis-ci.org/angeloashmore/immutable-ics?branch=master)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)

## Installation

```sh
npm install --save immutable-ics
```

## Quick Guide

### Import

Import the modules:

```js
import { Component, Property } from 'immutable-ics'
```

The following modules are available:

* `Component`: Typed Immutable `Record` to build an iCalendar Component
* `Property`: Typed Immutable `Record` to build an iCalendar Property

### Create a component

Create a new component and add properties:

```js
let calendar
let event

const versionProperty = new Property({ name: 'VERSION', value: 2 })

const dtstartProperty = new Property({
  name: 'DTSTART',
  parameters: { VALUE: 'DATE' },
  value: new Date('1991-07-11 7:00:00')
})

calendar = new Component({ name: 'VCALENDAR' })
calendar = calendar.pushProperty(versionProperty)

event = new Component({ name: 'VEVENT' })
event = event.pushProperty(dtstartProperty)

calendar = calendar.pushComponent(event)
```

Or instantiate everything at once:

```js
const calendar = new Component({
  name: 'VCALENDAR',
  properties: [
    new Property({ name: 'VERSION', value: 2 })
  ],
  components: [
    new Component({
      name: 'VEVENT',
      properties: [
        new Property({
          name: 'DTSTART',
          parameters: { VALUE: 'DATE' },
          value: new Date('1991-07-11 7:00:00')
        })
      ]
    })
  ]
})
```

### Generate iCalendar data

Call `#toString` on the `Component` or `Property` to get a string representation
of the component according to the iCalendar specifications.

```
calendar.toString()
```

Generated data:

```
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTART;VALUE=DATE:19910711
END:VEVENT
END:VCALENDAR
```

This string can then be saved to a file, sent to the user, etc.

## API

### `Component`

An Immutable `Record` with the following properties:

* `name: String`: Name of the component (e.g. "VCALENDAR", "VEVENT")
* `components: List<Component>`: List of `Component` instances
* `properties: List<Property>`: List of `Property` instances

All methods return a new instance of the component due to its backing on
Immutable's `Record`.

#### Extended Methods

* **`Component.constructor({ name: String, components: (List<Component> | Array<Component>), properties: (List<Property> | Array<Property>) }): Component`**

  Instantiate a new `Component` with initial values. `components` and
  `properties` will be coerced to a `List`.

* **`Component.prototype.pushComponent(component: Component): Component`**

  Push a `Component` to the list of components.

* **`Component.prototype.pushProperty(property: Property): Component`**

  Push a `Property` to the list of properties.

* **`Component.prototype.clear(): Component`**

  Clear all components and properties from the component.

* **`Component.prototype.clearComponents(): Component`**

  Clear all components from the component.

* **`Component.prototype.clearProperties(): Component`**

  Clear all properties from the component.

* **`Component.prototype.toString(): String`**

  Get a string representation of the component according to the iCalendar
  specifications.
  
### `Property`

An Immutable `Record` with the following properties:

* `name: String`: Name of the property (e.g. "DTSTART", "SUMMARY")
* `parameters: Map<String, Any>`: Property parameters (e.g. "VALUE")
* `transform: Boolean = true`: Explicit determiner if the value is transformed
* `value: Any`: Value of the property

All methods return a new instance of the property due to its backing on
Immutable's `Record`.

#### Extended Methods

* **`Property.constructor({ name: String, parameters: (Object | Map<String, Any>), transform: Boolean = true, value: Any }): Property`**

  Instantiate a new `Property` with initial values. `parameters` will be coerced
  into a `Map`.

* **`Property.prototype.getTransformedValue(): String`**

  Get the transformed value of the property's value. Transformations are
  conveniences to generate valid iCalendar data from JavaScript objects.
  
  For example, providing a `Date` object to a `DTSTAMP` property value will
  transform as such:
  
  ```js
  const dtstampProperty = new Property({
    name: 'DTSTAMP'
    parameters: { VALUE: 'DATE' },
    value: new Date('1991-07-11 7:00:00')
  })
  
  dtstampProperty.toString() // => DTSTAMP;VALUE=DATE:19910711
  ```

* **`Property.prototype.toString(): String`**

  Get a string representation of the property according to the iCalendar
  specifications.

[0]: https://github.com/typed-immutable/typed-immutable/
[1]: https://github.com/facebook/immutable-js/

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