3 Star 4 Fork 1

十里 / CoreJS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

介绍

CoreJS,一些js的常用标准接口实现,使高版本浏览器的标准接口,兼容低版本浏览器下运行

安装

npm i silis-corejs

Array

数组的常用方法

Array.forEach

forEach在日常编码经常需要使用,用作for循环,ES6内置已经实现,兼容ES6以下版本,则可用此代码

Array.map

方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值

Array.indexOf

查找指定元素所在位置,如果没有找到则返回-1

Array.distinct

将数组内元素去重复

String

字符串常用方法

String.trim

去掉字符串的开始和结尾的空格符、回车符和制表符

Object

对象常用方法

Object.assign

浅复制对象所有成员到第一个参数的对象中

Object.defineProperty

定义一个对象的属性,低版本浏览器只支持使置属性的value

HTMLDocument

document.addEventListener(""DOMContentLoaded"", function(){})

使低版本浏览器支持document.addEventListener(""DOMContentLoaded"", function(){})

document.getElementsByClassName

兼容低版本浏览器的document.getElementsByClassName

document.parse

兼容低版本浏览器的innerHTML无法使用自定义标签

不兼容代码示例:
document.body.innerHTML = "<vx>{{hello}}</vx>";
兼容代码示例:
document.body.innerHTML = "";
document.body.appendChild(document.parse("<vx>{{hello}}</vx>"));

sessionStorage

会话数据

sessionStorage.setItem(key,value)

设置一个key的会话数据

sessionStorage.getItem(key)

获取一个key的会话数据

sessionStorage.removeItem(key)

删除一个key的会话数据

sessionStorage.clear()

清除所有会话数据

localStorage

本地持久数据

localStorage.setItem(key,value)

设置一个key的本地持久数据

localStorage.getItem(key)

获取一个key的本地持久数据

localStorage.removeItem(key)

删除一个key的本地持久数据

localStorage.clear()

清除所有本地持久数据

MIT License Copyright (c) 2021 https://gitee.com/silis/CoreJS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

CoreJS,一些js的常用标准接口实现,使高版本浏览器的标准接口,兼容低版本浏览器下运行 展开 收起
JavaScript
MIT
取消

发行版 (20)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/silis/CoreJS.git
git@gitee.com:silis/CoreJS.git
silis
CoreJS
CoreJS
master

搜索帮助