Giter Site home page Giter Site logo

eachr's People

Contributors

balupton avatar dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar robloach avatar sfrdmn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

robloach

eachr's Issues

Your .dependabot/config.yml contained invalid details

Dependabot encountered the following error when parsing your .dependabot/config.yml:

The property '#/update_configs/0/automerged_updates/0/match/update_type' value "security" did not match one of the following values: all, security:patch, semver:patch, semver:minor, in_range

Please update the config file to conform with Dependabot's specification using our docs and online validator.

Callback entry types

Seems it would be possible to have the callback contain the values. Before the v7 typescript rewrite, I had done these types on jan 2 2019, perhaps they can work:
https://github.com/bevry/eachr/blob/381e347bd61b479b87b6309ba1e08112176b395d/source/index.d.ts

declare module 'eachr' {
	/** Internal type to make overloading the Subject easier. */
	type SubjectType<Key extends keyof any, Value> =
		| Array<Value>
		| Map<Key, Value>
		| Record<Key, Value>

	/** Internal type to make overloading the Key easier. */
	type KeyType<Subject> = Subject extends any[] ? number : keyof any

	/**
	 * The callback that is called with the details for each iteration of the subject.
	 * @param this The context is bound to the subject.
	 * @param value The value of the iteration.
	 * @param key The key of the iteration.
	 * @param subject The collection we are iterating.
	 * @returns Return `false` if you wish to break out of the iteration.
	 * @example
	 * ``` javascript
	 * // stop iterating when we encounter break
	 * eachr(['hello', 'world', 'break', 'never'], function (value, index) {
	 *   return value === 'break' ? false : console.log(value)
	 * })
	 * // ^ logs: hello, world
	 * ```
	 */
	export interface IteratorCallback<
		Subject extends SubjectType<Key, Value>,
		Key extends KeyType<Subject>,
		Value
	> {
		(
			this: Subject & SubjectType<Key, Value>,
			value: Value,
			key: Key,
			subject: Subject
		): void | boolean
	}

	/**
	 * Iterate through an Array, receiving the value and index.
	 * @example
	 * ``` javascript
	 * const arr = [1, 2 'three']
	 * eachr(arr, (value, key) => {})
	 * ```
	 */
	export default function eachr<
		Subject extends Array<Value>,
		Key extends KeyType<Subject>,
		Value
	>(
		subject: Subject & Array<Value>,
		callback: IteratorCallback<Subject, Key, Value>
	): typeof subject

	/**
	 * Iterate through an object, receiving the value and key.
	 * @example
	 * ``` javascript
	 * const obj = { a: 1, b: 'two' }
	 * eachr(obj, (value, key) => {})
	 * ```
	 */
	export default function eachr<
		Subject extends Record<Key, Value>,
		Key extends KeyType<Subject>,
		Value extends Subject[Key]
	>(
		subject: Subject & Record<Key, Value>,
		callback: IteratorCallback<Subject, Key, Value>
	): Object

	/**
	 * Iterate through a Map, receiving the value and key.
	 * @example
	 * ``` javascript
	 * const map = new Map<string, number | string>().set('a', 1).set('b', 'two')
	 * eachr(map, (value, key) => {})
	 * ```
	 */
	export default function eachr<
		Subject extends Map<Key, Value>,
		Key extends KeyType<Subject>,
		Value
	>(
		subject: Subject & Map<Key, Value>,
		callback: IteratorCallback<Subject, Key, Value>
	): typeof subject

	/** Iterate through the subject. */
	export default function eachr<
		Subject extends SubjectType<Key, Value>,
		Key extends KeyType<Subject>,
		Value
	>(
		subject: Subject & SubjectType<Key, Value>,
		callback: IteratorCallback<Subject, Key, Value>
	): typeof subject
}

However, as eachr is legacy tool, I'm not fussed, so closing.

Support 0.10 if it is still supported...

I'm not too fussed, as our test chain doesn't support 0.10... however our runtime code may...

If someone out there still depends on 0.10 support for this, post an issue and I will see what I can do.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.