Soup.first() - shysolocup/stews GitHub Wiki

gets the first entry
type: Function

alt names:

  • front()
  • start()

arguments:

  • ?offset Number
    optional offset from the first index

list: pair:
const { Soup } = require('stews');


let arr = new Soup([ "a", "b", "c" ]);


console.log(arr.first());
console.log(arr.first(1));
const { Soup } = require('stews');


let obj = new Soup({ key1: "val1", key2: "val2", key3: "val3" });


console.log(obj.first());
console.log(obj.first(1));
"a" // offset of 0 gets the first entry
"b" // offset of 1 gets the second entry
{ key: "key1", value: "val1", index: 0 } // offset of 0 gets the first entry
{ key: "key2", value: "val2", index: 0 } // offset of 1 gets the second entry


⚠️ **GitHub.com Fallback** ⚠️