JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 56
  • Score
    100M100P100Q62290F
  • License ISC

工具类

Package Exports

  • @soei/util
  • @soei/util/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@soei/util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

线上示例

工具类

const util = require("@soei/util");

// 或

import util from "@soei/util";

change

let change = util.change;

let a = change({
  source: [new Date(), new Date()],
  pick: {},
  name: "0=>name,1=>value",
  m: "YYYY/MM-DD hh:mm:ss",
});

console.log(a);
// { name: '2016/10-22 14:54:27', value: '2016/10-22 14:54:27' }
let a = change({
  source: new Date(),
  pick: {},
  name: "0=>name,1=>value",
  m: "YYYY",
});
// 或
let a = {};
change({
  source: new Date(),
  pick: a,
  name: "0=>name,1=>value",
  m: "YYYY",
});

console.log(a);
// { name: '2016'}

reset

/* 数据对象属性重置为[空字符串或者自定义] */
let reset = util.reset;
let _default = 0;
let data = {
  name: "balabal",
  age: 1,
};
reset(
  data,
  /* ignore 忽略的属性 */
  {
    age: null,
  },
  /* 默认 空字符串"" */
  _default
);
/* 
{
  name: "",
  age: 1,
}
*/

array2Json

/* 根据字符串配置,改变数组为映射表 */
let array2Json = util.array2Json;

let data = [{
    name: "balabal",
    age: 1,
}];
array2Json(data, 'age:name');
/* 
{ '1': 'balabal' }
*/