UNPKG

data-fns

Version:

This library provides utility functions for working with array data that are useful in many contexts, including creative coding. It offers generic functions that perform common operations such as offsetting an array, generating an array based on a callbac

17 lines (16 loc) 500 B
/** * Converts an array of binary digits to an array of indices where the digit is 1. * @param binary An array of binary digits (0 or 1). * @returns An array of indices where the digit is 1. * @example * binaryToIndices([1, 0, 1, 1, 0, 1]) * // Returns [0, 2, 3, 5] * * binaryToIndices([1, 1, 1, 1, 1]) * // Returns [0, 1, 2, 3, 4] * * binaryToIndices([0, 0, 0, 0, 0]) * // Returns [] * */ export declare const binaryToIndices: (binary: Array<number>) => Array<number>;