UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

16 lines (15 loc) 671 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getitem = getitem; const _operator_ts_1 = require("../_helpers/_operator.js"); function getitem(a, b) { // discuss at: https://locutus.io/python/operator/getitem/ // parity verified: Python 3.12 // original by: Kevin van Zonneveld (https://kvz.io) // note 1: Indexes strings and arrays with Python-style negative indexes and object key lookup. // example 1: getitem(['a', 'b', 'c'], -1) // returns 1: 'c' // example 2: getitem('banana', 2) // returns 2: 'n' return (0, _operator_ts_1.pythonGetItem)(a, b); }