npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

array-map-abc

v1.2.7

Published

array map function npm test

Downloads

8

Readme

数组原生的map方法在第5版中被添加到ECMA-262标准中;因此,它可能不存在于所有标准的实现中。这就是 array-map-abc 存在的原因,这个方法创建一个新数组,这个新数组由原数组中的每个元素都调用一次提供的函数后的返回值组成。

以下是array-map-abc的一些优点

  • 简单
  • 兼容性强
  • 体积小(gzip压缩后不到0.5KB)
  • 使用ts语法,有强大的代码提示和类型验证
  • 0 Dependencies

妈妈再也不用担心我不会用map方法了✌️

语法

let new_array = arrayMap(arr, function callback(currentValue[, index[, array]]) {
 // Return element for new_array 
}[, thisArg])

示例

const arrayMap = require("array-map-abc")
let arr = [1, 3, 5]
let new_array = arrayMap(arr, function(item) {
  return item * 2
})
// expected output: Array [2, 6, 10]

参数

arr  需要接受处理的原数组 callback  生成新数组元素的函数,使用三个参数:   currentValue: callback 数组中正在处理的当前元素。   index(可选): callback 数组中正在处理的当前元素的索引。   thisArg(可选): 在callback方法中指向需要处理的原数组(即第一个参数)。 thisArg(可选)  执行 callback 函数时值被用作this。

返回值

一个由原数组每个元素执行回调函数的结果组成的新数组。


创作不易,如果您用的舒心,可以联系我捐赠,分享给您的朋友🙏 本人精通javascript变量命名,如果您有什么疑问,也可以给我发邮件,免费教学