-toutputs what it's going to perform before performing it-Ireplaces occurrences of the argument with whatever is piped into it
cat file.txt | xargs sh -c "<command>; <commandtwo>"npm ls -g --depth=0 | grep -e '->' > npm-links.txt, the -e ensures that the - isn't treated as a flag.npm-links.txt to only the package paths.cat npm-links.txt | xargs -I '{}' -t sh -c 'cd {}; npm unlink'| function getLowestChild(tree) { | |
| if (!tree.children || !tree.children.length) { | |
| return { | |
| depth: 0, | |
| node: tree.root, | |
| } | |
| } | |
| const { depth, node } = tree.children.reduce( | |
| (curLowest, subTree) => { | |
| const nextLowest = getLowestChild(subTree) |
| type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> | |
| type Diff<T, U> = Omit<T, Extract<keyof U, keyof T>> | |
| // works because {} will extend a pick of an optional property | |
| // i.e. {} extends { foo?: string } because it's potentially undefined | |
| // abuses the fact that the compiler treats assignability specially for object types | |
| type OptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T] | |
| type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>> | |
| // in a weak type, the empty interface extends that type since all of its properties can be undefined |
| import { useReducer, ChangeEvent } from "react" | |
| import { map } from "../util" | |
| export type FieldSpec<T = any> = { | |
| initialValue: T | |
| validate?(value: T): boolean | |
| } | |
| export type FormAction<F, K extends keyof F = keyof F> = { | |
| fieldName: K |
| // definitions | |
| import { Middleware } from 'redux' | |
| export declare const dispatch: Dispatch | |
| export type State = unknown | |
| /** | |
| * General action type, DO NOT USE AS A RETURN TYPE |
| type State = any | |
| /** | |
| * General action type | |
| */ | |
| export type Action<TType extends string = string, TPayload = any> = TPayload extends undefined | |
| ? { | |
| type: TType | |
| } | |
| : { |
| import { RouteComponentProps } from '@reach/router' | |
| import { | |
| ComponentType, | |
| ComponentClass, | |
| FunctionComponent, | |
| JSXElementConstructor, | |
| ComponentProps, | |
| } from 'react' | |
| // method 1 |
| const prioritizedVals = { | |
| a: 0, | |
| b: 1, | |
| c: 2 | |
| } | |
| function sortWithPriority(a, b) { | |
| // if it's not a prioritized value the sort value is Infinity and falls back to default sorting | |
| const s1 = prioritizedVals[a] || Infinity | |
| const s2 = prioritizedVals[b] || Infinity |