Skip to content

Commit

Permalink
Merge pull request #76 from phodal/remove-lodash
Browse files Browse the repository at this point in the history
refactor: remove lodash  && fixed #65
  • Loading branch information
phodal authored Apr 8, 2020
2 parents fb3ebbd + 67fa789 commit a410ccd
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 309 deletions.
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"scripts": {
"ng": "./node_modules/.bin/ng",
"start": "yarn ng serve",
"build": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build",
"build:ci": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod",
"build:stats": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng --stats-json",
"build": "node --max_old_space_size=4096 ./node_modules/.bin/ng build",
"build:ci": "node --max_old_space_size=4096 ./node_modules/.bin/ng build --prod",
"build:stats": "node --max_old_space_size=4096 ./node_modules/.bin/ng build --stats-json",
"analyze": "webpack-bundle-analyzer dist/ledge/stats-es2015.json",
"test": "yarn ng test",
"test:ci": "yarn ng test --watch=false --progress=false --browsers=ChromeHeadlessCI --codeCoverage",
"lint": "yarn ng lint",
"commit": "git-cz",
"deploy": "yarn build:ci && npx angular-cli-ghpages --repo=https://github.com/phodal/do.git --dir=dist/static --cname=devops.phodal.com",
"build:lib": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build ledge-render --prod",
"build:lib": "node --max_old_space_size=4096 ./node_modules/.bin/ng build ledge-render --prod",
"publish:lib": "cd dist/ledge-render && npm publish --access=public",
"scully": "scully",
"scully:serve": "scully serve"
Expand Down Expand Up @@ -43,7 +43,6 @@
"dagre-d3": "^0.6.4",
"echarts": "^4.6.0",
"graphlib-dot": "^0.6.4",
"lodash-es": "^4.17.15",
"marked": "^0.8.0",
"material-design-icons": "^3.0.1",
"mermaid": "^8.4.8",
Expand All @@ -67,7 +66,6 @@
"@types/echarts": "^4.4.3",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/lodash": "^4.14.149",
"@types/node": "^12.11.1",
"angular-cli-ghpages": "^0.6.2",
"codelyzer": "^5.1.2",
Expand Down
1 change: 0 additions & 1 deletion projects/ledge-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"dagre-d3": "^0.6.4",
"echarts": "^4.7.0",
"graphlib-dot": "^0.6.4",
"lodash-es": "^4.17.15",
"marked": "^0.8.2",
"shortid": "^2.2.15"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import marked from 'marked/lib/marked';
import { zip } from 'lodash-es';
import { zip } from '../../utils/zip';

const LedgeMarkdownConverter = {
// marked
Expand Down
3 changes: 3 additions & 0 deletions projects/ledge-render/src/lib/utils/zip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function zip<T1, T2>(arr1: Array<T1>, arr2: Array<T2>): Array<[T1 | undefined, T2 | undefined]> {
return arr1.map((value, idx) => [value, arr2[idx]]);
}
8 changes: 3 additions & 5 deletions src/app/features/markdown-render/tocify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { last } from 'lodash-es';

export interface TocItem {
anchor: string;
level: number;
Expand Down Expand Up @@ -27,7 +25,7 @@ export default class Tocify {
// 第一个 item 直接 push
items.push(item);
} else {
let lastItem = last(items) as TocItem; // 最后一个 item
let lastItem = items[items.length - 1]; // 最后一个 item

if (item.level > lastItem.level) {
// item 是 lastItem 的 children
Expand All @@ -39,7 +37,7 @@ export default class Tocify {
break;
}

lastItem = last(children) as TocItem; // 重置 lastItem 为 children 的最后一个 item
lastItem = children[children.length - 1]; // 重置 lastItem 为 children 的最后一个 item

if (item.level <= lastItem.level) {
// item level 小于或等于 lastItem level 都视为与 children 同级
Expand All @@ -59,5 +57,5 @@ export default class Tocify {
reset = () => {
this.tocItems = [];
this.anchors = [];
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
OnInit,
SimpleChanges,
} from '@angular/core';
import { get } from 'lodash-es';

@Component({
selector: 'app-atom-details',
Expand All @@ -27,10 +26,10 @@ export class AtomDetailsComponent implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges) {
const { data = null } = changes;
this.phaseClass = {
gas: get(data, 'currentValue.phase', '') === 'gas',
solid: get(data, 'currentValue.phase', '') === 'solid',
unknown: get(data, 'currentValue.phase', '') === 'unknown',
liquid: get(data, 'currentValue.phase', '') === 'liquid',
gas: data?.currentValue?.phase === 'gas',
solid: data?.currentValue?.phase === 'solid',
unknown: data?.currentValue?.phase === 'unknown',
liquid: data?.currentValue?.phase === 'liquid',
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
Output,
SimpleChanges,
} from '@angular/core';
import { get } from 'lodash-es';
import { combineLatest, Observable, Subject } from 'rxjs';
import { debounceTime, map, startWith, takeUntil, tap } from 'rxjs/operators';
import { Atom, HighlightState } from '../shared';
Expand Down Expand Up @@ -129,13 +128,13 @@ export class PeriodicTableComponent implements OnInit, OnChanges {

ngOnChanges(changes: SimpleChanges) {
const { selectedMetal = null } = changes;
this.metalClass = get(selectedMetal, 'currentValue', null);
this.metalClass = selectedMetal?.currentValue || null;
}

showAtomDetails(atomNumber: number) {
if (atomNumber) {
this.currentAtom = this.atoms.find((a) => a.number === atomNumber);
this.currentAtomCategory.emit(get(this.currentAtom, 'category', null));
this.currentAtomCategory.emit(this.currentAtom?.category || null);
}
}

Expand Down

This file was deleted.

Empty file.

This file was deleted.

65 changes: 0 additions & 65 deletions src/app/presentation/home/process-table/process-table.component.ts

This file was deleted.

47 changes: 0 additions & 47 deletions src/app/shared/model/ledge-markdown-converter.spec.ts

This file was deleted.

Loading

0 comments on commit a410ccd

Please sign in to comment.