auto skip function args

https://repl.it/@xgqfrms/auto-skip-function-args


"use strict"; /**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2019-09-28
* @modified
*
* @description auto skip function args that not actually used
* @description Automatically skip parameters that are not actually used by the function
* @description 自动跳过函数实际上没有使用的参数
* @augments
* @example
* @link
*
*/ let log = console.log; // this OK
const autoSkipArgs = (fn, skipArgsNumber, args) => {
fn.apply(this, Array(skipArgsNumber).concat([args]));
} // function autoSkipArgs(fn, skipArgsNumber, args) {
// fn.apply(this, Array(skipArgsNumber).concat([args]));
// } export default autoSkipArgs; export {
autoSkipArgs,
}; // testing /* let log = console.log; const func = (arg1 = ``, arg2 = {}) => {
log(`arg1`, arg1);
log(`arg2`, arg2);
}; let obj = {
key: 1,
value: "A",
}; autoSkipArgs(func, 1, obj);
// arg1
// arg2 { key: 1, value: 'A' } */

array & empty bug

Uint8Array


new Uint8Array(2).map(i => "");
// Uint8Array(2) [0, 0]
new Uint8Array(2);
// Uint8Array(2) [0, 0]
[...new Uint8Array(2).map(i => "")]
// (2) [0, 0]
[...new Uint8Array(2)].map(i => "");
// (2) ["", ""]


site: www.stackoverflow.com js function ignore first arguments

https://stackoverflow.com/questions/32518615/skip-arguments-in-a-javascript-function

https://stackoverflow.com/questions/25642690/javascript-skip-arguments-in-function-call

https://stackoverflow.com/questions/38224231/how-to-remove-the-first-argument-of-function

https://stackoverflow.com/questions/37229000/why-cant-i-skip-parameter-assignments-in-a-function-signature


https://stackoverflow.com/questions/28770415/ecmascript-6-arrow-function-that-returns-an-object/57601889#57601889


shit antd & table col render

https://ant.design/components/table-cn/#Column

render(text, record, index)

https://codesandbox.io/s/antd-table-auto-skip-args-j1vu2


import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Table, Badge, Menu, Dropdown, Icon } from "antd"; const menu = (
<Menu>
<Menu.Item>Action 1</Menu.Item>
<Menu.Item>Action 2</Menu.Item>
</Menu>
); let log = console.log; function NestedTable() {
const columns = [
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Platform", dataIndex: "platform", key: "platform" },
{ title: "Version", dataIndex: "version", key: "version" },
{ title: "Upgraded", dataIndex: "upgradeNum", key: "upgradeNum" },
{
title: "Creator",
dataIndex: "creator",
key: "creator",
// render: (undefined, undefined, index) => {
// render: ("", "", index) => {
// render: ("x", "x", index) => {
render: (a, b, index) => {
log(`index`, index);
return <span>auto sikp args</span>;
}
},
{
title: "Date",
dataIndex: "createdAt",
key: "createdAt",
render: (text, record, index) => {
log(`text`, text, index);
// log(`record`, record);
return <span>{text}</span>;
}
},
{
title: "Action",
key: "operation",
render: (record, index) => {
// log(`record`, record, index);
return <a>Publish</a>;
}
}
]; const data = [];
for (let i = 0; i < 3; ++i) {
data.push({
key: i,
name: "Screem",
platform: "iOS",
version: "10.3.4.5654",
upgradeNum: 500,
creator: "Jack",
createdAt: "2014-12-24 23:12:00"
});
} return (
<Table
className="components-table-demo-nested"
columns={columns}
dataSource={data}
/>
);
} ReactDOM.render(<NestedTable />, document.getElementById("container"));

anonymous function args bug ???

(...[...new Uint8Array(2)].map(i => ""), 123) => {
console.log(arguments[0]);
};
// Uncaught SyntaxError: Unexpected token '...' copy(...[...new Uint8Array(2)].map(i => ""));
// undefined


arrow function & arguments bug



function abc(arg1, arg2) {
console.log(arguments[0]);
} abc(...[...new Uint8Array(2)].map(i => ""), 123); const f = (arg1, arg2) => {
console.log(arguments[0]);
}; f(...[...new Uint8Array(2)].map(i => ""), 123);
// VM769:2 Uncaught ReferenceError: arguments is not defined

auto skip function args的更多相关文章

  1. C++ 11 Lambda表达式、auto、function、bind、final、override

    接触了cocos2dx 3.0,就必须得看C++ 11了.有分享过帖子:[转帖]漫话C++0x(四) —- function, bind和lambda.其实最后的Lambda没太怎么看懂. 看不懂没关 ...

  2. 搞懂function(*args,**kwargs)

    给出一个例子: def foo(*args,**kwargs): print 'args=',args print 'kwargs=',kwargs print '------------------ ...

  3. 《理解 ES6》阅读整理:函数(Functions)(三)Function Constructor & Spread Operator

    增强的Function构造函数(Increased Capabilities of the Function Constructor) 在Javascript中Function构造函数可以让你创建一个 ...

  4. ES6新特性:Function函数扩展, 扩展到看不懂

    本文所有Demo的运行环境为nodeJS, 参考:让nodeJS支持ES6的词法----babel的安装和使用 : 函数的默认值: 如果有参数 ,那就用参数, 如果没有参数, 那就用默认的参数: aj ...

  5. KoaHub平台基于Node.js开发的Koa的skip插件代码详情

    koahub-skip koahub skip middleware koahub skip Conditionally skip a middleware when a condition is m ...

  6. python 中的 args,*args,**kwargs的区别

    一.*args的使用方法 *args 用来将参数打包成tuple给函数体调用 例子一:def function(*args):      print(args, type(args))function ...

  7. js的一些function

    /** * * 根据秒数返回 一个日期范围 * timerFilter(10) */ function timerFilter(n) { let days = 31; // 一月多少天 const o ...

  8. Mordern Effective C++ --auto

    5. 优先使用auto而非显示类型声明 在C++之中,使用auto关键字声明类型可以将程序员从输入繁琐的类型中解放出来,编译器会自动推导出变量的实际类型. template<typename I ...

  9. [JS] ECMAScript 6 - String, Number, Function : compare with c#

    字符串的扩展 正则的扩展 数值的扩展 函数的扩展 字符串的扩展 js 字符的 Unicode 表示法 codePointAt() String.fromCodePoint() 字符串的遍历器接口 at ...

随机推荐

  1. libevent之基于socket的bufferevent

    基于socket的bufferevent由一个socket的传输层和read/write buffer组成.区别于常规的event,当socket可读或者可写时会回调用户的callback,buffe ...

  2. Linux常用命令:文件操作命令

    Linux系统命令主要包括文件操作.网络命令和性能命令,本文介绍常用文件操作命令. 修改文件属性 文件类型: 普通文件:- 目录文件:d 块设备文件:b,硬盘 字符设备: c,串行端口的接口设备,例如 ...

  3. Spring Boot 系列总结

    Spring Boot 系列总结 1.SpringBoot自动装配 1.1 Spring装配方式 1.2 Spring @Enable 模块驱动 1.3 Spring 条件装配 2.自动装配正文 2. ...

  4. MySQL集群之MyCat

    MySQL集群之MyCat 一.MyCat简介及分析 1.1 MyCat是什么? 1.2 关键特性及应用场景 1.2.1 关键特性 1.2.2 应用场景 1.2.3 MyCat不适合的应用场景 1.3 ...

  5. 解决java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/Pattern

    明明引入了这个,却提示没有 看下面文章: http://www.maocaoying.com/article/109

  6. 在线安装mysql

    http://www.cnblogs.com/wishwzp/p/7113403.html

  7. shell(shell函数、shell正则表达式)

    本章内容 shell函数 shell正则表达式 1.shell函数 linux shell 可以用户定义函数,然后在shell脚本中可以随便调用. 格式: funname () { CMD #函数体 ...

  8. Linux常用命令详解(第一章)(ls、man、pwd、cd、mkdir、echo、touch、cp、mv、rm、rmdir、)

    本章命令(共11个): 1 2 3 4 5 6 ls man pwd cd mkdir echo touch cp mv rm rmdir 1. " ls " 作用:列出指定目录下 ...

  9. 2.centos 7清空文件和文件夹

    1.清空文件 测试文件:a.txt 1)方法一,[root@centos test]# > a.txt [root@centos test]# cat a.txt 1hjbfao hjkl23o ...

  10. IDLE怎么修改背景?

    摘要:IDLE默认为白色,可能有的人喜欢其他颜色,那么怎么修改呢? 颜色喜好,因人而异.不想千篇一律使用默认的白色,可以通过以下操作修改IDLE的背景颜色以及其他设置. 打开Python官方自带的ID ...