Skip to content

Instantly share code, notes, and snippets.

@Component({})
export class AppComponent {
readonly noneMessage = "nothing";
readonly selectSeat$ = new Subject<number>();
readonly selectedMessage$ = this.selectSeat$.pipe(
scan(registerSeats, new Set<number>()),
startWith(new Set<number>()),
map(set => (set.size ? Array.from(set).join(", ") : this.noneMessage)),
function expandObjWithStatus(obj, condition) {
return {
...obj,
...(condition && {
status: 'modified'
})
}
}
const client = {name: 'John', login: 'john45', secretKey: 'xyz123'};
const {secretKey, ...clientData} = client;
clientData // {name: 'John', login: 'john45'};
const environment = {
type: 'prod',
variables: {
api: 'some-url',
port: '8080'
}
}
const {
type: envType, // we extract "type" and call it "envType" here