pad()

The pad linq operator returns a new linq object that contains the elements of the collection and enough extra elements (each equal to the "padding" parameter) added to the end of the collection so that the entire collection has a length equal to the "width" parameter.
var arr = [1, 2, 3, 4];

// col1 = [1, 2, 3, 4, '*', '*', '*', '*']
var col1 = $linq(arr).pad(8, '*').toArray();

// col2 = [1, 2, 3, 4]
var col2 = $linq(arr).pad(3, '*').toArray();

padWith()

The padWith linq operator returns a new linq object that contains the elements of the collection and enough extra elements (each given by repeated invocations of the "paddingSelector" function) added to the end of the collection so that the entire collection has a length equal to the "width" parameter. The "paddingSelector" function is passed the index for which it is generating an element.
var arr = [0, 1, 2, 3]

// col1 = [0, 1, 2, 3, 44, 55, 66, 77]
var col1 = $linq(arr).padWith(8, 'x => (x * 10) + x').toArray();

// col2 = [0, 1, 2, 3]
var col2 = $linq(arr).pad(3, 'x => x * 11').toArray();

Last edited Oct 4, 2012 at 3:40 AM by battousai999, version 1