Skip to content

Commit

Permalink
Merge pull request #33 from mtsgi/feature/number-clamp
Browse files Browse the repository at this point in the history
Feature/number clamp
  • Loading branch information
mtsgi committed Jul 17, 2021
2 parents 57aa86b + 4c31428 commit 8d3c6ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/index.html
Expand Up @@ -315,6 +315,13 @@ <h3>Number#times</h3>
// 4
// 6</div></pre>
</section>

<section>
<h3>Number#clamp</h3>
<pre>32..clamp(-32, 64)<span>// => 32</span></pre>
<pre>256..clamp(-32, 64)<span>// => 64</span></pre>
<pre>(-128).clamp(-32, 64)<span>// => -32</span></pre>
</section>
</div>

<footer class="p-l m-b-l kit-sub kit-text-c">
Expand Down
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -75,7 +75,8 @@ export default class Bury {
prev_float () { return this - Number.EPSILON },
to_s () { return this.toString() },
inspect () { return this.to_s },
times (f) { for (const i of [...Array(this).keys()]) f.apply(window, [i]); return this }
times (f) { for (const i of [...Array(this).keys()]) f.apply(window, [i]); return this },
clamp (min, max) { return Math.min(Math.max(this, min), max) }
}
}
}
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "buryjs",
"version": "0.5.0",
"version": "0.5.1",
"description": "Ruby-like methods for JavaScript.",
"module": "index.js",
"main": "index.js",
Expand Down

0 comments on commit 8d3c6ea

Please sign in to comment.