Skip to content

Instantly share code, notes, and snippets.

if (typeof(SDK) == "undefined") {
SDK = {
__namespace: true
};
}
SDK.WEBAPI = {
_context: function () {
///
/// Private function to the context object.
///
@bbagdad
bbagdad / Javascript mapMany
Created April 26, 2018 08:55
JavaScript manMany
// Projects each element of a sequence to an Array and flattens the resulting sequences into one sequence.
if (!Array.prototype.mapMany) {
Object.defineProperty(Array.prototype, 'mapMany', {
value: function (callback) {
if (this === null) {
throw new TypeError('Array.prototype.mapMany ' +
'called on null or undefined');
}
if (typeof callback !== 'function') {
throw new TypeError(callback +
@bbagdad
bbagdad / Javascript mapMany
Created April 26, 2018 08:56
JavaScript manMany, Projects each element of a sequence to an Array and flattens the resulting sequences into one sequence.
// Projects each element of a sequence to an Array and flattens the resulting sequences into one sequence.
if (!Array.prototype.mapMany) {
Object.defineProperty(Array.prototype, 'mapMany', {
value: function (callback) {
if (this === null) {
throw new TypeError('Array.prototype.mapMany ' +
'called on null or undefined');
}
if (typeof callback !== 'function') {
throw new TypeError(callback +
@bbagdad
bbagdad / getValue
Created April 26, 2018 09:20
Object.prototye.getValue
/*
* Gets the value of the object by using the keys passed as string.
* Returns the value of the specified key, null if undefined.
*/
if (!Object.prototype.getValue) {
Object.prototype.getValue = function (key) {
var self = this;
if (!(self instanceof Object) || Object.keys(self).length == 0 || !key || typeof key !== 'string') {
return self;