Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: add functional equivalent of Array.prototype.copyWithin #203

Open
3 tasks done
kgryte opened this issue Jul 31, 2018 · 0 comments · May be fixed by #367
Open
3 tasks done

RFC: add functional equivalent of Array.prototype.copyWithin #203

kgryte opened this issue Jul 31, 2018 · 0 comments · May be fixed by #367
Labels
difficulty: 3 Likely to be challenging but manageable. Feature Issue or pull request for adding a new feature. Help Wanted Extra attention is needed. RFC Request for comments. Feature requests and proposed changes. Utilities Issue or pull request concerning general utilities.

Comments

@kgryte
Copy link
Member

kgryte commented Jul 31, 2018

Checklist

Please ensure the following tasks are completed before submitting a feature request.

  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.

Description

Description of the feature request.

This RFC proposes to add a "functional" equivalent of Array.prototype.copyWithin and TypedArray.prototype.copyWithin.

Package: @stdlib/utils/copy-within
Alias: copyWithin

The interface would be as follows:

/**
* @param {Collection} collection - input collection
* @param {integer} target - target index
* @param {integer} [start=0] - source start index
* @param {integer} [end=collection.length] - source end index
* @returns {Collection} modified input collection
*/
function copyWithin( collection, target ) {
    if ( !isCollection( collection ) ) {
        throw new TypeError( '...' );
    }
    // implementation...
}

If a provided collection has a built-in copyWithin method, the implementation would defer to that method. Otherwise, the implementation would provide a "polyfill", thus extending copyWithin support to environments lacking the built-in API for Array and TypedArray.

Related Issues

Does this feature request have any related issues?

No.

Questions

Any questions for reviewers?

No.

Other

Any other information relevant to this feature request? This may include screenshots, references, sample output, and/or implementation notes.

No.

@kgryte kgryte added Help Wanted Extra attention is needed. RFC Request for comments. Feature requests and proposed changes. Feature Issue or pull request for adding a new feature. difficulty: 3 Likely to be challenging but manageable. Utilities Issue or pull request concerning general utilities. labels Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 3 Likely to be challenging but manageable. Feature Issue or pull request for adding a new feature. Help Wanted Extra attention is needed. RFC Request for comments. Feature requests and proposed changes. Utilities Issue or pull request concerning general utilities.
Projects
None yet
1 participant