Skip to content

Commit

Permalink
[CORE] Fix ci runner and tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
smialy committed Nov 9, 2018
1 parent 4ceddc7 commit f01d56e
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 87 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test-ci:
npm install --no-save [email protected] @babel/[email protected] \
npm install --no-save [email protected] [email protected] @babel/[email protected] \
@babel/[email protected] @babel/plugin-transform-modules-commonjs@^7.1.0 \
[email protected]
[email protected] [email protected] [email protected] [email protected]
./node_modules/.bin/lerna run test
./node_modules/.bin/lerna run lint

Expand Down
22 changes: 11 additions & 11 deletions packages/sjs-core/dist/esm/function.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sid as randomSid } from './random';
import { getType } from './types';
import { sid } from './random';
export const noop = () => { };
export const noop = () => { }; // tslint:disable-line
/*
* Pick first value without error
*
Expand All @@ -15,12 +15,12 @@ export const noop = () => { };
* @return {Object}
*/
export function tr(...args) {
for (let fn of args) {
for (const fn of args) {
try {
return fn();
}
catch (e) {
//noop
// noop
}
}
return null;
Expand All @@ -47,19 +47,19 @@ function cloneInner(o, m = null) {
if (!o) {
return o;
}
let t = getType(o);
const t = getType(o);
if (t === 'date') {
return new Date(o.getTime());
}
if (t === 'array' || t === 'object') {
if (o[MARKER]) {
return m[o[MARKER]];
}
let clear = !m;
const clear = !m;
m = m || {};
let _sid = sid();
o[MARKER] = _sid;
m[_sid] = o;
const sid = randomSid();
o[MARKER] = sid;
m[sid] = o;
let _;
switch (t) {
case 'array':
Expand All @@ -70,13 +70,13 @@ function cloneInner(o, m = null) {
break;
case 'object':
_ = {};
for (let key of Object.keys(o)) {
for (const key of Object.keys(o)) {
_[key] = cloneInner(o[key], m);
}
break;
}
if (clear) {
for (let key of Object.keys(m)) {
for (const key of Object.keys(m)) {
if (m[key][MARKER]) {
m[key][MARKER] = null;
delete m[key][MARKER];
Expand Down
12 changes: 6 additions & 6 deletions packages/sjs-core/dist/esm/random.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ export function choice(sequence) {
* @return {String}
*/
export function sid(len = 32) {
//start from letter (can be use as DOM id)
let sid = String.fromCharCode(Math.floor((Math.random() * 25) + 65));
while (sid.length < len) {
// start from letter (can be use as DOM id)
let id = String.fromCharCode(Math.floor((Math.random() * 25) + 65));
while (id.length < len) {
// between [48,57](number) + [65,90](ascii)
let code = Math.floor((Math.random() * 42) + 48);
const code = Math.floor((Math.random() * 42) + 48);
if (code < 58 || code > 64) {
sid += String.fromCharCode(code);
id += String.fromCharCode(code);
}
}
return sid;
return id;
}
/**
* Genereate sequense hash
Expand Down
2 changes: 1 addition & 1 deletion packages/sjs-core/dist/esm/string.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function camelCase(text) {
* @return {String}
*/
export function hyphenate(text) {
return text.replace(/[A-Z]/g, match => '-' + match.charAt(0).toLowerCase());
return text.replace(/[A-Z]/g, (match) => '-' + match.charAt(0).toLowerCase());
}
/**
* Format string
Expand Down
57 changes: 35 additions & 22 deletions packages/sjs-core/dist/esm/types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export function getType(o) {
}
return map[getTag(o)] || 'object';
}
const prepareType = expectType => o => map[getTag(o)] === expectType;
export const isNull = o => o === null;
export const isUndefined = o => o === undefined;
const prepareType = (expectType) => (o) => map[getTag(o)] === expectType;
export const isNull = (o) => o === null;
export const isUndefined = (o) => o === undefined;
/**
* @type {Function}
* @return {Boolean}
Expand All @@ -63,58 +63,71 @@ export const isDate = prepareType('date');
* @method sjs.isObject
* @return {Boolean}
*/
export const isObject = o => o != null && typeof o === 'object';
export const isObject = (o) => o != null && typeof o === 'object';
/**
* @method sjs.isNumber
* @return {Boolean}
*/
export const isNumber = o => typeof o === 'number';
export const isNumber = (o) => typeof o === 'number';
/**
* @method sjs.isString
* @return {Boolean}
*/
export const isString = o => getType(o) === 'string';
export const isString = (o) => getType(o) === 'string';
/**
* @method sjs.isFunction
* @return {Boolean}
*/
export const isFunction = o => typeof o === 'function';
export const isGenerator = o => getTag(o) === '[object GeneratorFunction]';
export const isAsync = o => getTag(o) === '[object AsyncFunction]';
export const isSymbol = o => getType(o) === 'symbol';
export const isSet = o => getTag(o) === '[object Set]';
export const isMap = o => getTag(o) === '[object Map]';
export const isFunction = (o) => typeof o === 'function';
export const isGenerator = (o) => getTag(o) === '[object GeneratorFunction]';
export const isAsync = (o) => getTag(o) === '[object AsyncFunction]';
export const isSymbol = (o) => getType(o) === 'symbol';
export const isSet = (o) => getTag(o) === '[object Set]';
export const isMap = (o) => getTag(o) === '[object Map]';
/**
* @method sjs.isBoolean
* @return {Boolean}
*/
export const isBoolean = o => typeof o === 'boolean';
export const isBoolean = (o) => typeof o === 'boolean';
/**
* @method sjs.isElement
* @return {Boolean}
*/
export const isElement = o => getType(o) === 'element';
export const isElement = (o) => getType(o) === 'element';
/**
* @method sjs.isTextnode
* @return {Boolean}
*/
export const isTextnode = o => getType(o) === 'textnode';
export const isTextnode = (o) => getType(o) === 'textnode';
/**
* @method sjs.isWhitespace
* @return {Boolean}
*/
export const isWhitespace = o => getType(o) === 'whitespace';
export const isWhitespace = (o) => getType(o) === 'whitespace';
/**
* @method sjs.isCollection
* @return {Boolean}
*/
export const isCollection = o => getType(o) === 'collection';
export const isCollection = (o) => getType(o) === 'collection';
function buildTypesMap() {
const map = {};
let names = ['Number', 'String', 'Function', 'AsyncFunction', 'GeneratorFunction', 'Array', 'Object', 'Date', 'RegExp', 'Boolean', 'Arguments', 'Symbol'];
const types = {};
const names = [
'Number',
'String',
'Function',
'AsyncFunction',
'GeneratorFunction',
'Array',
'Object',
'Date',
'RegExp',
'Boolean',
'Arguments',
'Symbol',
];
for (const name of names) {
map['[object ' + name + ']'] = name.toLowerCase();
types['[object ' + name + ']'] = name.toLowerCase();
}
map['[object AsyncFunction]'] = 'async';
return map;
types['[object AsyncFunction]'] = 'async';
return types;
}
22 changes: 11 additions & 11 deletions packages/sjs-core/dist/node/function.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("./types");
const random_1 = require("./random");
exports.noop = () => { };
const types_1 = require("./types");
exports.noop = () => { }; // tslint:disable-line
/*
* Pick first value without error
*
Expand All @@ -17,12 +17,12 @@ exports.noop = () => { };
* @return {Object}
*/
function tr(...args) {
for (let fn of args) {
for (const fn of args) {
try {
return fn();
}
catch (e) {
//noop
// noop
}
}
return null;
Expand Down Expand Up @@ -50,19 +50,19 @@ function cloneInner(o, m = null) {
if (!o) {
return o;
}
let t = types_1.getType(o);
const t = types_1.getType(o);
if (t === 'date') {
return new Date(o.getTime());
}
if (t === 'array' || t === 'object') {
if (o[MARKER]) {
return m[o[MARKER]];
}
let clear = !m;
const clear = !m;
m = m || {};
let _sid = random_1.sid();
o[MARKER] = _sid;
m[_sid] = o;
const sid = random_1.sid();
o[MARKER] = sid;
m[sid] = o;
let _;
switch (t) {
case 'array':
Expand All @@ -73,13 +73,13 @@ function cloneInner(o, m = null) {
break;
case 'object':
_ = {};
for (let key of Object.keys(o)) {
for (const key of Object.keys(o)) {
_[key] = cloneInner(o[key], m);
}
break;
}
if (clear) {
for (let key of Object.keys(m)) {
for (const key of Object.keys(m)) {
if (m[key][MARKER]) {
m[key][MARKER] = null;
delete m[key][MARKER];
Expand Down
12 changes: 6 additions & 6 deletions packages/sjs-core/dist/node/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ exports.choice = choice;
* @return {String}
*/
function sid(len = 32) {
//start from letter (can be use as DOM id)
let sid = String.fromCharCode(Math.floor((Math.random() * 25) + 65));
while (sid.length < len) {
// start from letter (can be use as DOM id)
let id = String.fromCharCode(Math.floor((Math.random() * 25) + 65));
while (id.length < len) {
// between [48,57](number) + [65,90](ascii)
let code = Math.floor((Math.random() * 42) + 48);
const code = Math.floor((Math.random() * 42) + 48);
if (code < 58 || code > 64) {
sid += String.fromCharCode(code);
id += String.fromCharCode(code);
}
}
return sid;
return id;
}
exports.sid = sid;
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/sjs-core/dist/node/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports.camelCase = camelCase;
* @return {String}
*/
function hyphenate(text) {
return text.replace(/[A-Z]/g, match => '-' + match.charAt(0).toLowerCase());
return text.replace(/[A-Z]/g, (match) => '-' + match.charAt(0).toLowerCase());
}
exports.hyphenate = hyphenate;
/**
Expand Down
Loading

0 comments on commit f01d56e

Please sign in to comment.