Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ircam/sc-utils

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ircam/sc-utils - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

src/counter.js

5

package.json
{
"name": "@ircam/sc-utils",
"version": "1.7.0",
"version": "1.8.0",
"contributors": [

@@ -35,3 +35,4 @@ "Benjamin Matuszewski",

"@ircam/sc-gettime": "^1.0.1",
"is-plain-obj": "^4.1.0"
"is-plain-obj": "^4.1.0",
"number-precision": "^1.6.0"
},

@@ -38,0 +39,0 @@ "devDependencies": {

261

README.md

@@ -19,29 +19,30 @@ # sc-utils

* [atodb][1]
* [dbtoa][2]
* [decibelToLinear][3]
* [decibelToPower][4]
* [delay][5]
* [exponentialScale][6]
* [ftom][7]
* [getTime][8]
* [hertzToNormalised][9]
* [idGenerator][10]
* [isBrowser][11]
* [isFunction][12]
* [isNumber][13]
* [isPlainObject][14]
* [isSequence][15]
* [isString][16]
* [isTouchDevice][17]
* [isTypedArray][18]
* [isURL][19]
* [linearScale][20]
* [linearToDecibel][21]
* [logarithmicScale][22]
* [mtof][23]
* [normalisedToHertz][24]
* [normalizedToTableScale][25]
* [powerToDecibel][26]
* [sleep][27]
* [tableToNormalizedScale][28]
* [counter][2]
* [dbtoa][3]
* [decibelToLinear][4]
* [decibelToPower][5]
* [delay][6]
* [exponentialScale][7]
* [ftom][8]
* [getTime][9]
* [hertzToNormalised][10]
* [idGenerator][11]
* [isBrowser][12]
* [isFunction][13]
* [isNumber][14]
* [isPlainObject][15]
* [isSequence][16]
* [isString][17]
* [isTouchDevice][18]
* [isTypedArray][19]
* [isURL][20]
* [linearScale][21]
* [linearToDecibel][22]
* [logarithmicScale][23]
* [mtof][24]
* [normalisedToHertz][25]
* [normalizedToTableScale][26]
* [powerToDecibel][27]
* [sleep][28]
* [tableToNormalizedScale][29]

@@ -56,3 +57,3 @@ ## atodb

* `val` **[number][29]** Value to convert
* `val` **[number][30]** Value to convert

@@ -67,4 +68,22 @@ ### Examples

Returns **[number][29]** 
Returns **[number][30]** 
## counter
Create a counter function.
### Parameters
* `from` **[number][30]** Start of the counter, included (optional, default `0`)
* `to` **[number][30]** End of the counter, included (optional, default `Nmuber.MAX_SAFE_INTEGER`)
* `step` **[number][30]** Increment / decrement step, if 0 returns `from` forever (optional, default `1`)
Returns **[Function][31]** import { counter } from '@ircam/sc-utils';
const myCounter = counter(0.1, 0.3, 0.1);
counter(); // 0.1
counter(); // 0.2
counter(); // 0.3
counter(); // 0.1
// ...
## dbtoa

@@ -78,3 +97,3 @@

* `val` **[number][29]** Value to convert
* `val` **[number][30]** Value to convert

@@ -89,3 +108,3 @@ ### Examples

Returns **[number][29]** 
Returns **[number][30]** 

@@ -100,3 +119,3 @@ ## decibelToLinear

* `val` **[number][29]** Value to convert
* `val` **[number][30]** Value to convert

@@ -111,3 +130,3 @@ ### Examples

Returns **[number][29]** 
Returns **[number][30]** 

@@ -120,3 +139,3 @@ ## decibelToPower

* `val` **[number][29]** Value to convert
* `val` **[number][30]** Value to convert

@@ -131,3 +150,3 @@ ### Examples

Returns **[number][29]** 
Returns **[number][30]** 

@@ -142,3 +161,3 @@ ## delay

* `ms` **[Number][29]** Number of milliseconds to wait
* `ms` **[Number][30]** Number of milliseconds to wait

@@ -153,3 +172,3 @@ ### Examples

Returns **[Promise][30]** 
Returns **[Promise][32]** 

@@ -162,8 +181,8 @@ ## exponentialScale

* `inputStart` **[number][29]** Start value of input range
* `inputEnd` **[number][29]** End value of input range
* `outputStart` **[number][29]** Start value of output range
* `outputEnd` **[number][29]** End value of output range
* `base` **[number][29]** Base value for exponential scaling, default to `2` (optional, default `2`)
* `clip` **[boolean][31]** Clip output to output range, default to `false` (optional, default `false`)
* `inputStart` **[number][30]** Start value of input range
* `inputEnd` **[number][30]** End value of input range
* `outputStart` **[number][30]** Start value of output range
* `outputEnd` **[number][30]** End value of output range
* `base` **[number][30]** Base value for exponential scaling, default to `2` (optional, default `2`)
* `clip` **[boolean][33]** Clip output to output range, default to `false` (optional, default `false`)

@@ -185,3 +204,3 @@ ### Examples

* `freq` **[number][29]** Frequency to convert
* `freq` **[number][30]** Frequency to convert

@@ -196,3 +215,3 @@ ### Examples

Returns **[number][29]** 
Returns **[number][30]** 

@@ -212,3 +231,3 @@ ## getTime

// ...
}, 1000)
}, 1000);
```

@@ -224,4 +243,4 @@

* `frequencyHertz` **[number][29]** Frequency in Hertz to convert
* `sampleRate` **[number][29]** Twice the Nyquist frequency (optional, default `{}`)
* `frequencyHertz` **[number][30]** Frequency in Hertz to convert
* `sampleRate` **[number][30]** Twice the Nyquist frequency (optional, default `{}`)

@@ -238,3 +257,3 @@ * `sampleRate.sampleRate` (optional, default `2`)

Returns **[number][29]** 
Returns **[number][30]** 

@@ -245,2 +264,4 @@ ## idGenerator

*DEPRECATED* Use the more generic and user friendly `counter` instead.
### Examples

@@ -268,3 +289,3 @@

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -287,3 +308,3 @@ ## isFunction

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -307,3 +328,3 @@ ## isNumber

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -326,3 +347,3 @@ ## isPlainObject

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -345,3 +366,3 @@ ## isSequence

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -364,3 +385,3 @@ ## isString

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -379,3 +400,3 @@ ## isTouchDevice

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -398,3 +419,3 @@ ## isTypedArray

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -418,3 +439,3 @@ ## isURL

Returns **[boolean][31]** 
Returns **[boolean][33]** 

@@ -427,7 +448,7 @@ ## linearScale

* `inputStart` **[number][29]** Start value of input range
* `inputEnd` **[number][29]** End value of input range
* `outputStart` **[number][29]** Start value of output range
* `outputEnd` **[number][29]** End value of output range
* `clip` **[boolean][31]** Clip output to output range, default to `false` (optional, default `false`)
* `inputStart` **[number][30]** Start value of input range
* `inputEnd` **[number][30]** End value of input range
* `outputStart` **[number][30]** Start value of output range
* `outputEnd` **[number][30]** End value of output range
* `clip` **[boolean][33]** Clip output to output range, default to `false` (optional, default `false`)

@@ -443,3 +464,3 @@ ### Examples

Returns **[Function][32]** 
Returns **[Function][31]** 

@@ -454,3 +475,3 @@ ## linearToDecibel

* `val` **[number][29]** Value to convert
* `val` **[number][30]** Value to convert

@@ -465,3 +486,3 @@ ### Examples

Returns **[number][29]** 
Returns **[number][30]** 

@@ -474,8 +495,8 @@ ## logarithmicScale

* `inputStart` **[number][29]** Start value of input range
* `inputEnd` **[number][29]** End value of input range
* `outputStart` **[number][29]** Start value of output range
* `outputEnd` **[number][29]** End value of output range
* `base` **[number][29]** Base value for exponential scaling, default to `2` (optional, default `2`)
* `clip` **[boolean][31]** Clip output to output range, default to `false` (optional, default `false`)
* `inputStart` **[number][30]** Start value of input range
* `inputEnd` **[number][30]** End value of input range
* `outputStart` **[number][30]** Start value of output range
* `outputEnd` **[number][30]** End value of output range
* `base` **[number][30]** Base value for logarithmic scaling, default to `2` (optional, default `2`)
* `clip` **[boolean][33]** Clip output to output range, default to `false` (optional, default `false`)

@@ -485,4 +506,4 @@ ### Examples

```javascript
const { exponentialScale } = utils;
const freqToMidi = exponentialScale(69, 81, 440, 880);
const { logarithmicScale } = utils;
const freqToMidi = logarithmicScale(440, 880, 69, 81);
freqToMidi(220);

@@ -498,3 +519,3 @@ // > 57

* `midiNote` **[number][29]** MIDI Note to convert
* `midiNote` **[number][30]** MIDI Note to convert

@@ -509,3 +530,3 @@ ### Examples

Returns **[number][29]** 
Returns **[number][30]** 

@@ -520,4 +541,4 @@ ## normalisedToHertz

* `frequencyNormalised` **[number][29]** Normalised frequency to convert
* `sampleRate` **[number][29]** Twice the Nyquist frequency (optional, default `{}`)
* `frequencyNormalised` **[number][30]** Normalised frequency to convert
* `sampleRate` **[number][30]** Twice the Nyquist frequency (optional, default `{}`)

@@ -534,3 +555,3 @@ * `sampleRate.sampleRate` (optional, default `2`)

Returns **[number][29]** 
Returns **[number][30]** 

@@ -544,3 +565,3 @@ ## normalizedToTableScale

* `transfertTable` **[Array][33]<[number][29]>** Sequence of finite numbers to use as lookup table
* `transfertTable` **[Array][34]<[number][30]>** Sequence of finite numbers to use as lookup table

@@ -559,3 +580,3 @@ ### Examples

Returns **[function][32]**&#x20;
Returns **[function][31]**&#x20;

@@ -568,3 +589,3 @@ ## powerToDecibel

* `val` **[number][29]** Value to convert
* `val` **[number][30]** Value to convert

@@ -579,3 +600,3 @@ ### Examples

Returns **[number][29]**&#x20;
Returns **[number][30]**&#x20;

@@ -590,3 +611,3 @@ ## sleep

* `sec` **[Number][29]** Number of seconds to wait
* `sec` **[Number][30]** Number of seconds to wait

@@ -601,3 +622,3 @@ ### Examples

Returns **[Promise][30]**&#x20;
Returns **[Promise][32]**&#x20;

@@ -611,3 +632,3 @@ ## tableToNormalizedScale

* `transfertTable` **[Array][33]<[number][29]>** Sequence of finite numbers to use as lookup table
* `transfertTable` **[Array][34]<[number][30]>** Sequence of finite numbers to use as lookup table

@@ -626,70 +647,72 @@ ### Examples

Returns **[function][32]**&#x20;
Returns **[function][31]**&#x20;
[1]: #atodb
[2]: #dbtoa
[2]: #counter
[3]: #decibeltolinear
[3]: #dbtoa
[4]: #decibeltopower
[4]: #decibeltolinear
[5]: #delay
[5]: #decibeltopower
[6]: #exponentialscale
[6]: #delay
[7]: #ftom
[7]: #exponentialscale
[8]: #gettime
[8]: #ftom
[9]: #hertztonormalised
[9]: #gettime
[10]: #idgenerator
[10]: #hertztonormalised
[11]: #isbrowser
[11]: #idgenerator
[12]: #isfunction
[12]: #isbrowser
[13]: #isnumber
[13]: #isfunction
[14]: #isplainobject
[14]: #isnumber
[15]: #issequence
[15]: #isplainobject
[16]: #isstring
[16]: #issequence
[17]: #istouchdevice
[17]: #isstring
[18]: #istypedarray
[18]: #istouchdevice
[19]: #isurl
[19]: #istypedarray
[20]: #linearscale
[20]: #isurl
[21]: #lineartodecibel
[21]: #linearscale
[22]: #logarithmicscale
[22]: #lineartodecibel
[23]: #mtof
[23]: #logarithmicscale
[24]: #normalisedtohertz
[24]: #mtof
[25]: #normalizedtotablescale
[25]: #normalisedtohertz
[26]: #powertodecibel
[26]: #normalizedtotablescale
[27]: #sleep
[27]: #powertodecibel
[28]: #tabletonormalizedscale
[28]: #sleep
[29]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[29]: #tabletonormalizedscale
[30]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
[30]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[31]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[31]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[32]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
[33]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[33]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[34]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
<!-- apistop -->

@@ -696,0 +719,0 @@

@@ -11,4 +11,4 @@ /**

* // ...
* }, 1000)
* }, 1000);
*/
export { getTime } from '@ircam/sc-gettime';
/**
* Create a iterator of incrementing ids
*
* _DEPRECATED_ Use the more generic and user friendly `counter` instead.
*
* @return {Iterator}

@@ -4,0 +7,0 @@ * @example

@@ -57,1 +57,2 @@ // ---------------------------------------------------

export { idGenerator } from './id-generator.js';
export { counter } from './counter.js';

@@ -8,8 +8,8 @@ /**

* @param {number} outputEnd - End value of output range
* @param {number} [base=2] - Base value for exponential scaling, default to `2`
* @param {number} [base=2] - Base value for logarithmic scaling, default to `2`
* @param {boolean} [clip=false] - Clip output to output range, default to `false`
*
* @example
* const { exponentialScale } = utils;
* const freqToMidi = exponentialScale(69, 81, 440, 880);
* const { logarithmicScale } = utils;
* const freqToMidi = logarithmicScale(440, 880, 69, 81);
* freqToMidi(220);

@@ -16,0 +16,0 @@ * // > 57

/**
* Create a iterator of incrementing ids
*
* _DEPRECATED_ Use the more generic and user friendly `counter` instead.
*
* @return {Iterator}

@@ -4,0 +7,0 @@ * @example

@@ -29,2 +29,3 @@ export { isBrowser } from "./is-browser.js";

export { idGenerator } from "./id-generator.js";
export { counter } from "./counter.js";
//# sourceMappingURL=index.d.ts.map

@@ -8,8 +8,8 @@ /**

* @param {number} outputEnd - End value of output range
* @param {number} [base=2] - Base value for exponential scaling, default to `2`
* @param {number} [base=2] - Base value for logarithmic scaling, default to `2`
* @param {boolean} [clip=false] - Clip output to output range, default to `false`
*
* @example
* const { exponentialScale } = utils;
* const freqToMidi = exponentialScale(69, 81, 440, 880);
* const { logarithmicScale } = utils;
* const freqToMidi = logarithmicScale(440, 880, 69, 81);
* freqToMidi(220);

@@ -16,0 +16,0 @@ * // > 57

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc