Skip to content

Commit

Permalink
Add jsdoc to iterable-to-string.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mroderick committed Sep 2, 2019
1 parent e677228 commit 18ce530
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/iterable-to-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ var slice = require("@sinonjs/commons").prototypes.string.slice;
var typeOf = require("@sinonjs/commons").typeOf;
var valueToString = require("@sinonjs/commons").valueToString;

/**
* Creates a string represenation of an iterable object
*
* @private
* @param {object} obj The iterable object to stringify
* @returns {string} A string representation
*/
function iterableToString(obj) {
if (typeOf(obj) === "map") {
return mapToString(obj);
Expand All @@ -12,6 +19,13 @@ function iterableToString(obj) {
return genericIterableToString(obj);
}

/**
* Creates a string representation of a Map
*
* @private
* @param {Map} map The map to stringify
* @returns {string} A string representation
*/
function mapToString(map) {
var representation = "";

Expand All @@ -24,6 +38,13 @@ function mapToString(map) {
return representation;
}

/**
* Create a string represenation for an iterable
*
* @private
* @param {object} iterable The iterable to stringify
* @returns {string} A string representation
*/
function genericIterableToString(iterable) {
var representation = "";

Expand All @@ -36,6 +57,13 @@ function genericIterableToString(iterable) {
return representation;
}

/**
* Creates a string representation of the passed `item`
*
* @private
* @param {object} item The item to stringify
* @returns {string} A string representation of `item`
*/
function stringify(item) {
return typeof item === "string" ? "'" + item + "'" : valueToString(item);
}
Expand Down

0 comments on commit 18ce530

Please sign in to comment.