Skip to content
Adam Smith edited this page Mar 3, 2016 · 10 revisions

vitals.fill npm version

Method Section Alias
fill base
fill.object base fill.obj
fill.array base fill.arr
fill.string base fill.str

fill

Fills an array, object, or string with specified values.

Examples

Params

  1. source ?(Array|Object|function|number)
If source is a number returns a new string filled with the value x times.
  1. keys (!Array|string)=
Only use with an object/function source. If defined it is considered an array of keys that will limit the fill action. If a string is defined it is converted to an array using one of the values in the following list for the separator (values listed in order of rank):
  - `", "`
  - `","`
  - `"|"`
  - `" "`
  1. val *
The value to fill the array, object, or string with.
  1. start number=
default value: ` 0 `

 Only for use with source arrays.
  1. end number=
default value: ` source.length `

 Only for use with source arrays.

Returns ?(Array|Object|function|string)

fill.object

Fills an existing object/function with specified keys and values.

Examples

Params

  1. obj (!Object|function)
  2. keys (!Array|string)=
If defined it is considered an array of keys that will limit the fill action. If a string is defined it is converted to an array using one of the values in the following list for the separator (values listed in order of rank):
  - `", "`
  - `","`
  - `"|"`
  - `" "`
  1. val *

Returns (!Object|function)

fill.array

Fills an existing or new array with specified values.

Examples

Params

  1. arr (!Array|number)
If number makes new array with arr length.
  1. val *
  2. start number=
default value: ` 0 `
  1. end number=
default value: ` arr.length `

Returns !Array

fill.string

Fills a new string with specified values.

Examples

Params

  1. count number
  2. val *
All val types are converted to string via `String(val)`.

Returns string

-- Happy Developing,

Algorithm IV Logo

Clone this wiki locally