Pot.Struct.fill

{Array|Object|*} Pot.Struct.fill ({Array|Object|*} defaults, {*} value, {Number} count)

Pot.js で利用可能。 PotLite.js では利用できません。

指定された値を 指定の数だけ埋めて返します。

引数 defaults はデフォルトの値 (型) を指定します。
引数 value は埋める値を指定します。
引数 count は埋める数を指定します。

Pot.globalize() が適応されている場合、Pot.fill() が fill() で実行できます。

defaults に value を count のぶんだけ埋めた新しいオブジェクトが返ります。

Pot.debug(Pot.fill([1, 2], 3, 5));
// [1, 2, 3, 3, 3, 3, 3]

Pot.debug(Pot.fill([], null, 3));
// [null, null, null]

Pot.debug(Pot.fill('foo', 'o', 10));
// 'foooooooooooo'

Pot.debug(Pot.fill('', 'hoge', 5));
// 'hogehogehogehogehoge'

Pot.debug(Pot.fill({}, 2, 5));
// {'0': 2, '1': 2, '2': 2, '3': 2, '4': 2}

Pot.debug(Pot.fill({a: 1, b: 2, c: 3}, null));
// {a: null, b: null, c: null}

Pot.debug(Pot.fill(100, 5, 10));
// 5555555555100