Skip to the content

Hoshi Stars星

The stars you can see without a telescope, with names, colours and distances; the 88 constellations with their lines and boundaries; the Messier objects; and seven map projections to draw them on.

Hoshi is the Japanese word 星 for a star. About the name

Contents

Reference · What is near a star, an object or a point, in the sky and in space; neighbouring constellations

NearestListtype

A list of answers, nearest first, with skipped: how many candidates had no usable distance and so were left out of a query by: "space" (a parallax of 0 or less, or a deep-sky object). It is 0 for a query by angle.

Import it

import type { NearestList } from "@johnmorrisdotca/hoshi-stars/nearest";

Definition

type NearestList<T> = T[] & {
    skipped: number;
};

Members

NameTypeDescription
lengthnumber

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

toString(): string

Returns a string representation of an array.

toLocaleString(): string (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string

Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.

pop(): T | undefined

Removes the last element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.

push(...items: T[]): number

Appends new elements to the end of an array, and returns the new length of the array.

concat(...items: ConcatArray<T>[]): T[] (...items: (T | ConcatArray<T>)[]): T[]

Combines two or more arrays. This method returns a new array without modifying any existing arrays.

join(separator?: string): string

Adds all the elements of an array into a string, separated by the specified separator string.

reverse(): T[]

Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array.

shift(): T | undefined

Removes the first element from an array and returns it. If the array is empty, undefined is returned and the array is not modified.

slice(start?: number, end?: number): T[]

Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.

sort(compareFn?: ((a: T, b: T) => number) | undefined): NearestList<T>

Sorts an array in place. This method mutates the array and returns a reference to the same array.

splice(start: number, deleteCount?: number): T[] (start: number, deleteCount: number, ...items: T[]): T[]

Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

unshift(...items: T[]): number

Inserts new elements at the start of an array, and returns the new length of the array.

indexOf(searchElement: T, fromIndex?: number): number

Returns the index of the first occurrence of a value in an array, or -1 if it is not present.

lastIndexOf(searchElement: T, fromIndex?: number): number

Returns the index of the last occurrence of a specified value in an array, or -1 if it is not present.

every<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is S[] (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean

Determines whether all the members of an array satisfy the specified test.

some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean

Determines whether the specified callback function returns true for any element of an array.

forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void

Performs the specified action for each element in an array.

map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]

Calls a defined callback function on each element of an array, and returns an array that contains the results.

filter<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[] (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]

Returns the elements of an array that meet the condition specified in a callback function.

reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T <U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T <U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

find<S extends T>(predicate: (value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined (predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined

Returns the value of the first element in the array where predicate is true, and undefined otherwise.

findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number

Returns the index of the first element in the array where predicate is true, and -1 otherwise.

fill(value: T, start?: number, end?: number): NearestList<T>

Changes all array elements from start to end index to a static value and returns the modified array

copyWithin(target: number, start: number, end?: number): NearestList<T>

Returns the this object after copying a section of the array identified by start and end to the same array starting at position target

entries(): ArrayIterator<[number, T]>

Returns an iterable of key, value pairs for every entry in the array

keys(): ArrayIterator<number>

Returns an iterable of keys in the array

values(): ArrayIterator<T>

Returns an iterable of values in the array

includes(searchElement: T, fromIndex?: number): boolean

Determines whether an array includes a certain element, returning true or false as appropriate.

flatMap<U, This = undefined>(callback: (this: This, value: T, index: number, array: T[]) => U | readonly U[], thisArg?: This | undefined): U[]

Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1.

flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[]

Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.

at(index: number): T | undefined

Returns the item located at the specified index.

findLast<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined (predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined

Returns the value of the last element in the array where predicate is true, and undefined otherwise.

findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number

Returns the index of the last element in the array where predicate is true, and -1 otherwise.

toReversed(): T[]

Returns a copy of an array with its elements reversed.

toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[]

Returns a copy of an array with its elements sorted.

toSpliced(start: number, deleteCount: number, ...items: T[]): T[] (start: number, deleteCount?: number): T[]

Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. Copies an array and removes elements while returning the remaining elements.

with(index: number, value: T): T[]

Copies an array, then overwrites the value at the provided index with the given value. If the index is negative, then it replaces from the end of the array.

skippednumber

Examples

import { nearest } from "@johnmorrisdotca/hoshi-stars/nearest";

const found = nearest("Sirius", { by: "space", count: 3 });
console.log(found.length, found.skipped > 2000);
3 true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hoshi-stars 0.7.0.