Skip to content

Instantly share code, notes, and snippets.

View SirM2z's full-sized avatar
💪
Tomorrow comes never.

Ryan SirM2z

💪
Tomorrow comes never.
View GitHub Profile
const PENDING = 'pending';
const FULFILLED = 'fulfilled';
const REJECTED = 'rejected';
function Promise(executor) {
let self = this;
self.status = PENDING;
self.onFulfilled = [];//成功的回调
self.onRejected = []; //失败的回调
//PromiseA+ 2.1
function resolve(value) {
const PENDING = 'PENDING';
const FULFILLED = 'FULFILLED';
const REJECTED = 'REJECTED';
class Promise {
constructor(exceutor) {
this.status = PENDING;
this.value = undefined;
this.reason = undefined;
this.onFulfilledCallbacks = [];
const PENDING = "pending";
const RESOLVED = "resolved"; // fulfilled
const REJECTED = "rejected"; //rejected
class Promise {
// 构造函数接受一个执行器作为参数
constructor(executor) {
// promise 状态
this.status = PENDING;
this.value = undefined;
@SirM2z
SirM2z / formatDate-jstool.js
Created April 19, 2018 06:23
js 时间格式化
// value 可选 new Date、时间戳、"2016-08-05 14:22:09" 时间格式
// fmt 可选 以下格式(以及位置调换)
// yyyy-MM-dd hh:mm:ss
// yyyy-MM-dd hh:mm:ss.S
// yyyy/MM/dd hh:mm:ss
// yyyy年MM月dd日 hh时mm分ss秒
// yyyyMMddhhmmss
function formatDate (value, fmt) {
// let v = value.replace(/-/g, "/").substring(0, 19);
let date = new Date(value)
@SirM2z
SirM2z / html5_Notification.js
Last active November 24, 2017 07:29
chrome console snippets
(function() {
const NotificationInstance = Notification || window.Notification;
if (!!NotificationInstance) {
const permissionNow = NotificationInstance.permission;
// 'default' 用户还未被询问是否授权,所以通知不会被显示
// 'granted' 表示之前已经询问过用户,并且用户已经授予了显示通知的权限
// 'denied' 用户已经明确的拒绝了显示通知的权限
if (permissionNow === 'granted') {
// 允许通知
CreatTask();

Keybase proof

I hereby claim:

  • I am SirM2z on github.
  • I am coolm_z (https://keybase.io/coolm_z) on keybase.
  • I have a public key whose fingerprint is B055 BC1A BD57 C6EF 6D66 5608 3B45 0968 C69D 4172

To claim this, I am signing this object: