Skip to content

cyclic-prev.js.org - #12715

Closed
abhisekp wants to merge 4 commits into
js-org:masterfrom
abhisekp:add-cyclic-prev
Closed

abhisekp wants to merge 4 commits into
js-org:masterfrom
abhisekp:add-cyclic-prev

Conversation

@abhisekp

Copy link
Copy Markdown
Contributor

The site content is an interactive playground and API documentation for cyclic-prev, a published dependency-free JavaScript npm package, and is relevant to JavaScript developers specifically because it demonstrates real package behavior, backward cyclic index arithmetic, CommonJS and ES module usage, TypeScript support, and practical carousel, weekday, and round-robin examples.

Repository: https://github.com/abhisekp/cyclic-prev
npm package: https://www.npmjs.com/package/cyclic-prev

GitHub Pages uses a GitHub Actions deployment and its custom domain has been saved as cyclic-prev.js.org in Pages settings. The source CNAME file and generated gh-pages artifact record the same domain. Assets are local and relative; the site serves its own content at the custom domain without redirecting away from JS.ORG. The GitHub Pages URL may redirect to the requested domain while DNS activation is pending.

This request adds exactly one alphabetically ordered line to cnames_active.js: "cyclic-prev": "abhisekp.github.io/cyclic-prev", matching the cyclic-next request in #12713.

The dedicated add-cyclic-prev branch starts from upstream master and contains only this entry, keeping the existing cyclic-next request in #12713 unchanged.

@github-actions

Copy link
Copy Markdown

✅ All validations passed! Please wait for the JS.org maintainers to process your subdomain request.

@indus

indus commented Oct 12, 2026

Copy link
Copy Markdown
Member

@abhisekp I'm not convinced by your content and why so simple functions would need a page and subdomain. Why are you splitting prev and next into two seperated functions, libraries, seperated pages, seperated npm packages.
Why not just this:

/**
 * Move through a cycle of max positions.
 * @param {number} max Number of positions (positive safe integer).
 * @param {number} [curr=0] Current position.
 * @param {number} [step=1] Step size (negative for previous).
 * @returns {number} The normalized position in [0, max).
 */
function cyclic(max, curr = 0, step = 1) {
  if (!Number.isSafeInteger(max) || max <= 0)
    throw new RangeError('max must be a positive safe integer');

  if (!Number.isSafeInteger(curr) || !Number.isSafeInteger(step))
    throw new TypeError('curr and step must be safe integers');

  const mod = n => ((n % max) + max) % max;
  return mod(mod(curr) + mod(step));
}

export default cyclic;

I mean are you going to request cyclic-three next for a fixed coded version that always jumps 3 next?

@MattIPv4 MattIPv4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Commit valid, CNAME present, site appears to have content *

* based off https://github.com/abhisekp/cyclic-prev/blob/gh-pages/index.html

@MattIPv4 MattIPv4 added add This PR/issue is regarding adding a new subdomain user This PR/issue is regarding a target on a GitHub user account project This PR has a target of a project on an organisation or user account labels Oct 12, 2026
@indus

indus commented Oct 12, 2026

Copy link
Copy Markdown
Member

@MattIPv4 What do you think of this content-wise. It boiles down to: https://github.com/abhisekp/cyclic-prev/blob/master/src/cyclicPrev.js

In #12713 we had the same but only next instead of prev: https://github.com/abhisekp/cyclic-next/blob/master/src/cyclicNext.js (basically the same but in th eother direction and without checks). To be honest I havn't check this back then to notice how trivial it is.

@indus indus added the awaiting response This PR is waiting for a response to move forward label Oct 12, 2026
@indus indus closed this Oct 12, 2026
@indus indus reopened this Oct 12, 2026
@abhisekp

abhisekp commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

@indus it's trivial but in my experience with the beginners, this is something which they feel very uncomfortable and don't write their own. This is a good one. I thought of publishing this in npm 10 yrs ago back when I published cyclic-next but due to other commitments, I had forgotten.
Now this is published in npm.

I didn't make it cyclic because it doesn't make much sense reading the name of the package 10 yrs ago. And already 12 yrs ago a package with the same name was present. https://www.npmjs.com/package/cyclic

@MattIPv4

MattIPv4 commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

🤔 What's stopping cyclic-next having an argument for reversing the direction, rather than an entire new package? Surely if your target audience is begineers you'd want this to be as discoverable possible, and so making it part of the existing package, and the existing subdomain, would be better?

@MattIPv4

Copy link
Copy Markdown
Member

@MattIPv4 What do you think of this content-wise. It boiles down to: https://github.com/abhisekp/cyclic-prev/blob/master/src/cyclicPrev.js

I think in isolation it is fine, which is why I approved, but I can also see how given the context of the previous subdomain, it may make sense to combine it instead. I don't really have super strong feelings either way.

@indus indus removed the awaiting response This PR is waiting for a response to move forward label Oct 12, 2026
@indus

indus commented Oct 12, 2026

Copy link
Copy Markdown
Member

Fine - Welcome https://cyclic-prev.js.org
this is the last cyclic — or any other <20 LOC function — I'm willing to tolerate.

@indus

indus commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

@abhisekp I've just saw that this PR needs to be rebased before I can merge. I've just added it manually

indus added a commit that referenced this pull request Oct 12, 2026
@indus indus closed this Oct 12, 2026
@indus indus reopened this Oct 13, 2026
@indus indus closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add This PR/issue is regarding adding a new subdomain project This PR has a target of a project on an organisation or user account user This PR/issue is regarding a target on a GitHub user account

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants