0.1.0 • Published 6 years ago

@dogmalang/reminder v0.1.0

Weekly downloads
1
License
-
Repository
bitbucket
Last release
6 years ago

@dogmalang/reminder

NPM version Total downloads

A reminder implementation.

Developed in Dogma, compiled to JavaScript.

Engineered in Valencia, Spain, EU by Justo Labs.

Use

The package must be imported as follows:

////////////////
// JavaScript //
////////////////
import Reminder from "@dogmalang/reminder";

#########
# Dogma #
#########
use "@dogmalang/reminder" as Reminder

Constructor

////////////////
// JavaScript //
////////////////
constructor(items:array, opts:{max:number})
constructor(opts:{max:number})

#########
# Dogma #
#########
type Reminder(items:list, opts:{max:num})
type Reminder(opts:{max:num})
  • items, the initial items.
  • opts, the options: max, maximum number of items to remind.

Examples:

////////////////
// JavaScript //
////////////////
r = new Reminder({max: 123})

#########
# Dogma #
#########
r = Queue({max=123})

append() and push()

Add a new item at the end of the reminder:

////////////////
// JavaScript //
////////////////
append(item) : Reminder
push(item) : Reminder

#########
# Dogma #
#########
@alias("append")
fn Reminder.push(item) -> self

The method returns the queue for chaining other appends. If the reminder has the maximum number of items to remind, the oldest is removed for generating gap to the new one.

Example:

r.push("one").push("two").push("three")

pop()

Remove the latest item and returning it:

////////////////
// JavaScript //
////////////////
pop() : any

#########
# Dogma #
#########
fn Reminder.pop() : any

If the reminder is empty, an error is raised.

Example:

i = r.pop()

len

Return the current length:

////////////////
// JavaScript //
////////////////
len : number

#########
# Dogma #
#########
fn Reminder.len : num

Example:

size = r.len

max

Return the maximum size:

////////////////
// JavaScript //
////////////////
max : number

#########
# Dogma #
#########
@prop
fn Reminder.max() : num

isEmpty()

Check whether the reminder is empty:

////////////////
// JavaScript //
////////////////
isEmpty() : boolean

#########
# Dogma #
#########
fn Reminder.isEmpty() : bool

Example:

r.isEmpty()

isFull()

Check whether the reminder is full:

////////////////
// JavaScript //
////////////////
isFull() : boolean

#########
# Dogma #
#########
fn Reminder.isFull() : bool

list()

Return a list with the reminded items:

////////////////
// JavaScript //
////////////////
list() : any[]

#########
# Dogma #
#########
fn Reminder.list() : list

Example:

r.list()
0.1.0

6 years ago