How to use array-last - 6 common examples

To help you get started, we’ve selected a few array-last examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fanfoujs / space-fanfou / src / features / show-contextual-statuses / @page.js View on Github external
const aliveInstance = cacheMap.get(cacheId)
      const maybeDeadInstance = li.nextElementSibling

      if (maybeDeadInstance?.matches(`.${CLASSNAME_CONTAINER}`)) {
        maybeDeadInstance.replaceWith(aliveInstance)
      }

      return
    }

    const replyLink = select('.stamp .reply a', li)
    const props = {
      type: replyLink.textContent.startsWith('转自')
        ? 'repost'
        : 'reply',
      initialStatusId: arrayLast(replyLink.href.split('/')),
    }

    preactRender(, instance => {
      // 调整插入位置
      li.after(instance)
      cacheMap.set(cacheId, instance)
    })
  }
github soumak77 / firebase-mock / src / firebase.js View on Github external
key () {
    return last(this.path.split('/')) || null
  }
  toString () {
github fanfoujs / space-fanfou / src / features / check-saved-searches / service@background.js View on Github external
const headers = { 'X-Requested-With': 'XMLHttpRequest' }
    const response = await wretch(url).query(data).headers(headers).get().json()
    const document = parseHTML(response.data.timeline)
    const statuses = Array.from(document.body.children)
    const latestStatusMatchingKeyword = statuses[0]
    const latestFilteredStatus = statuses.find(li => !isPotentiallyReadStatus(li, loggedInUserId))

    if (!latestStatusMatchingKeyword) return null
    if (latestFilteredStatus) return latestFilteredStatus
    if (pageNumber >= MAX_PAGES_TO_SEARCH) return null

    const nextPageStatus = await searchKeyword(
      loggedInUserId,
      keyword,
      pageNumber + 1,
      extractStatusId(arrayLast(statuses)),
    )

    if (nextPageStatus) return nextPageStatus
    if (pageNumber > 1) return null

    return latestStatusMatchingKeyword
  }
github vorpaljs / bash-parser / packages / bash-parser / src / modes / posix / tokenizer / reducers / expansion-arithmetic.js View on Github external
export default function expansionArithmetic(state, source) {
	const char = source && source.shift();

	const xp = last(state.expansion);

	if (char === ')' && state.current.slice(-1)[0] === ')') {
		return {
			nextReduction: state.previousReducer,
			nextState: state
				.appendChar(char)
				.replaceLastExpansion({
					type: 'arithmetic_expansion',
					expression: xp.value.slice(0, -1),
					loc: Object.assign({}, xp.loc, {end: state.loc.current})
				})
				.deleteLastExpansionValue()
		};
	}

	if (char === undefined) {
github vorpaljs / bash-parser / packages / bash-parser / src / modes / posix / tokenizer / reducers / expansion-special-parameter.js View on Github external
export default function expansionSpecialParameter(state, source) {
	const char = source && source.shift();

	const xp = last(state.expansion);

	return {
		nextReduction: state.previousReducer,
		nextState: state.appendChar(char).replaceLastExpansion({
			parameter: char,
			type: 'parameter_expansion',
			loc: Object.assign({}, xp.loc, {end: state.loc.current})
		})
	};
}
github vorpaljs / bash-parser / src / modes / posix / tokenizer / reducers / expansion-special-parameter.js View on Github external
export default function expansionSpecialParameter(state, char) {
	const xp = last(state.expansion);

	const newXp = {
		...xp,
		parameter: char,
		type: 'parameter_expansion',
		loc: {...xp.loc, end: state.loc.current}
	};

	const expansion = state.expansion
		.slice(0, -1)
		.concat(newXp);

	return {
		nextReduction: state.previousReducer,
		nextState: {...state, current: state.current + char, expansion}
	};

array-last

Get the last or last n elements in an array.

MIT
Latest version published 7 years ago

Package Health Score

68 / 100
Full package analysis

Popular array-last functions