1 Star 0 Fork 0

fastutils/excel-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
string.js 4.51 KB
一键复制 编辑 原始数据 按行查看 历史
wangmiao 提交于 2020-05-27 22:34 . fixed bugs
const utils = require('./utils');
const PropertyInfo = require('./property');
const forStringByIndexAndSetter = (column, setter) => forStringByIndexAndSetterAndRequired(column, setter, utils.DEFAULT_REQUIRED);
const forStringByIndexAndSetterAndRequired = (column, setter, required) => forStringByIndexAndSetterAndValidator(column, setter, utils.defaultPropertyRequiredValidator(required));
const forStringByIndexAndSetterAndValidator = (column, setter, validator) => forStringByRangeAndCreatorAndReaderAndSetterAndValidator(column, column, utils.defaultCreator, utils.defaultPropertySetter(setter), utils.defaultSetter, utils.defaultPropertyValidator(validator));
const forStringByRangeAndSetter = (minColumn, maxColumn, setter) => forStringByRangeAndSetterAndRequired(minColumn, maxColumn, setter, utils.DEFAULT_REQUIRED);
const forStringByRangeAndSetterAndRequired = (minColumn, maxColumn, setter, required) => forStringByRangeAndSetterAndValidator(minColumn, maxColumn, setter, utils.defaultPropertyRequiredValidator(required));
const forStringByRangeAndSetterAndValidator = (minColumn, maxColumn, setter, validator) => forStringByRangeAndCreatorAndReaderAndSetterAndValidator(minColumn, maxColumn, utils.defaultCreator, utils.defaultPropertySetter(setter), utils.defaultSetter, utils.defaultPropertyValidator(validator));
const forStringByIndexAndCreatorAndReaderAndSetter = (column, creator, reader, setter) => forStringByIndexAndCreatorAndReaderAndSetterAndRequired(column, creator, reader, setter, utils.DEFAULT_REQUIRED);
const forStringByIndexAndCreatorAndReaderAndSetterAndRequired = (column, creator, reader, setter, required) => forStringByIndexAndCreatorAndReaderAndSetterAndValidator(column, creator, reader, setter, utils.defaultRequiredValidator(required));
const forStringByIndexAndCreatorAndReaderAndSetterAndValidator = (column, creator, reader, setter, validator) => forStringByRangeAndCreatorAndReaderAndSetterAndValidator(column, column, creator, reader, setter, validator);
const forStringByRangeAndCreatorAndReaderAndSetter = (minColumn, maxColumn, creator, reader, setter) => forStringByRangeAndCreatorAndReaderAndSetterAndRequired(minColumn, maxColumn, creator, reader, setter, utils.DEFAULT_REQUIRED);
const forStringByRangeAndCreatorAndReaderAndSetterAndRequired = (minColumn, maxColumn, creator, reader, setter, required) => forStringByRangeAndCreatorAndReaderAndSetterAndValidator(minColumn, maxColumn, creator, reader, setter, utils.defaultRequiredValidator(required));
const forStringByRangeAndCreatorAndReaderAndSetterAndValidator = (minColumn, maxColumn, creator, reader, setter, validator) => {
return new PropertyInfo(minColumn, maxColumn, cell => {
return cell.value;
}, creator, reader, setter, validator);
};
const forString = (...args) => {
let lastBoolean = utils.isBoolean(args[args.length - 1]);
if (utils.isFunction(args[1])) {
if (args.length === 2) {
return forStringByIndexAndSetter(...args);
} else if (args.length === 3) {
if (lastBoolean) {
return forStringByIndexAndSetterAndRequired(...args);
} else {
return forStringByIndexAndSetterAndValidator(...args);
}
} else if (args.length === 4) {
return forStringByIndexAndCreatorAndReaderAndSetter(...args);
} else if (args.length === 5) {
if (lastBoolean) {
return forStringByIndexAndCreatorAndReaderAndSetterAndRequired(...args);
} else {
return forStringByIndexAndCreatorAndReaderAndSetterAndValidator(...args);
}
}
} else {
if (args.length === 3) {
return forStringByRangeAndSetter(...args);
} else if (args.length === 4) {
if (lastBoolean) {
return forStringByRangeAndSetterAndRequired(...args);
} else {
return forStringByRangeAndSetterAndValidator(...args);
}
} else if (args.length === 5) {
return forStringByRangeAndCreatorAndReaderAndSetter(...args);
} else if (args.length === 6) {
if (lastBoolean) {
return forStringByRangeAndCreatorAndReaderAndSetterAndRequired(...args);
} else {
return forStringByRangeAndCreatorAndReaderAndSetterAndValidator(...args);
}
}
}
}
module.exports = forString;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fastutils/excel-js.git
git@gitee.com:fastutils/excel-js.git
fastutils
excel-js
excel-js
master

搜索帮助