Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
# Copyright (c) 2016-2018 Ming Qin (覃明) <https://github.com/QinMing> | |
# Open source under MIT LICENSE. | |
lazy_load() { | |
# Act as a stub to another shell function/command. When first run, it will load the actual function/command then execute it. | |
# E.g. This made my zsh load 0.8 seconds faster by loading `nvm` when "nvm", "npm" or "node" is used for the first time | |
# $1: space separated list of alias to release after the first load | |
# $2: file to source | |
# $3: name of the command to run after it's loaded | |
# $4+: argv to be passed to $3 |
(function() { | |
/** | |
* 记录方法使用情况的类 | |
* @param {Array.<boolean>} umMap 初始的使用情况 | |
*/ | |
var UsageManager = function(umMap) { | |
this.umMap = umMap || []; | |
}; | |
/** | |
* 记录新的使用情况 |
function convertToCSV(objArray) { | |
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray; | |
var str = ''; | |
for (var i = 0; i < array.length; i++) { | |
var line = ''; | |
for (var index in array[i]) { | |
if (line != '') line += ',' | |
line += array[i][index]; |
xcodebuild -workspace XXX.xcworkspace -scheme XXX clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep '^\d\{3,\}[.]\{1\}' |
// This is a coding exercise of implementing a parser. Some minor parsing capabilities are not implemented. | |
// The algorithm are mainly from Douglas Crockford's 'https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js' | |
function json_parse(str) { | |
var i = 0 | |
var ch = str[i] | |
// core function that recursively called to move forward scanning pointers and accept tokens | |
function next(c) { | |
if (c) { |
import { __RouterContext as RouterContext, RouteComponentProps } from 'react-router' | |
import { useContext, useMemo, useCallback } from 'react' | |
import qs from 'qs' | |
import { Location } from 'history' | |
interface ParsedQuery { | |
[whatever: string]: any | |
} | |
export const useRouter = <T>(): RouteComponentProps<T> => |
// | |
// AppStoreUpdate.swift | |
// | |
// Created by CodeChanger on 03/11/19. | |
// Copyright © 2019 CodeChanger. All rights reserved. | |
// | |
import UIKit | |
enum CustomError: Error { |
1 | LAFBD-41 | |
---|---|---|
2 | SSNI-497 | |
3 | ABP-984 | |
4 | IPX-580 | |
5 | IPX-811 | |
6 | IPX-177 | |
7 | STARS-804 | |
8 | SMBD-115 | |
9 | ABP-968 | |
10 | ABF-017 |