Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 馃崺 #365

Merged
merged 1 commit into from Apr 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
187 changes: 187 additions & 0 deletions emoji.js
@@ -0,0 +1,187 @@
// Returns the results of applying the 馃崜 to each 馃崸 of the 馃尩
// In contrast to 馃憙.馃檱 it returns an 馃尩
馃憙.馃檱馃尩 = function (馃崋, 馃崻, 馃憴) {
馃崻 = cb(馃崻, 馃憴);
var 馃悜 = 馃憙.馃悜(馃崋),
length = 馃悜.length,
results = {},
馃惎;
for (var 馃挧 = 0; 馃挧 < length; 馃挧++) {
馃惎 = 馃悜[馃挧];
results[馃惎] = 馃崻(馃崋[馃惎], 馃惎, 馃崋);
}
return results;
};

// Convert an 馃尩 into a list of `[馃悆, 馃拵]` 馃崄.
馃憙.馃崄 = function (馃崋) {
var 馃悜 = 馃憙.馃悜(馃崋);
var length = 馃悜.length;
var 馃崄 = 馃惏(length);
for (var i = 0; i < length; i++) {
馃崄[i] = [馃悜[i], 馃崋[馃悜[i]]];
}
return 馃崄;
};

// Invert the 馃悜 and 馃拵s of an 馃尩. The 馃拵s must be serializable.
馃憙.invert = function (馃崋) {
var result = {};
var 馃悜 = 馃憙.馃悜(馃崋);
for (var i = 0, length = 馃悜.length; i < length; i++) {
result[馃崋[馃悜[i]]] = 馃悜[i];
}
return result;
};

// Return a sorted man of the function 馃懖 available on the 馃尩.
// Aliased as `methods`
馃憙.functions = 馃憙.methods = function (馃崋) {
var 馃懖 = [];
for (var 馃悆 in 馃崋) {
if (馃憙.isFunction(馃崋[馃悆])) 馃懖.push(馃悆);
}
return 馃懖.sort();
};

// An internal function for creating assigner functions.
var 馃惙 = function (馃悜Func, 鉀碉笍) {
return function (馃崋) {
var length = 馃尭.length;
if (length < 2 || 馃崋 == null) return 馃崋;
for (var 馃挧 = 1; 馃挧 < length; 馃挧++) {
var 馃拞 = 馃尭[馃挧],
馃悜 = 馃悜Func(馃拞),
l = 馃悜.length;
for (var i = 0; i < l; i++) {
var 馃悆 = 馃悜[i];
if (!鉀碉笍 || 馃崋[馃悆] === void 0) 馃崋[馃悆] = 馃拞[馃悆];
}
}
return 馃崋;
};
};

// Extend a given 馃尩 with all the 馃殾 in passed-in 馃尩(s).
馃憙.extend = 馃惙(馃憙.all馃悜);

// Assigns a given 馃尩 with all the own 馃殾 in the passed-in 馃尩(s)
馃憙.extendOwn = 馃憙.assign = 馃惙(馃憙.馃悜);

// Returns the first 馃悆 on an 馃尩 that passes a 鈽旓笍 test
馃憙.find馃悆 = function (馃崋, 鈽旓笍, 馃憴) {
鈽旓笍 = cb(鈽旓笍, 馃憴);
var 馃悜 = 馃憙.馃悜(馃崋),
馃悆;
for (var i = 0, length = 馃悜.length; i < length; i++) {
馃悆 = 馃悜[i];
if (鈽旓笍(馃崋[馃悆], 馃悆, 馃崋)) return 馃悆;
}
};

// Return a copy of the 馃尩 only containing the whitelisted 馃殾.
馃憙.pick = function (馃尩, o馃崻, 馃憴) {
var result = {}, 馃崋 = 馃尩,
馃崻, 馃悜;
if (馃崋 == null) return result;
if (馃憙.isFunction(o馃崻)) {
馃悜 = 馃憙.all馃悜(馃崋);
馃崻 = optimizeCb(o馃崻, 馃憴);
} else {
馃悜 = 馃拤(馃尭, false, false, 1);
馃崻 = function (馃拵, 馃悆, 馃崋) {
return 馃悆 in 馃崋;
};
馃崋 = 馃尩(馃崋);
}
for (var i = 0, length = 馃悜.length; i < length; i++) {
var 馃悆 = 馃悜[i];
var 馃拵 = 馃崋[馃悆];
if (馃崻(馃拵, 馃悆, 馃崋)) result[馃悆] = 馃拵;
}
return result;
};

// Return a copy of the 馃尩 without the blacklisted 馃殾.
馃憙.omit = function (馃崋, 馃崻, 馃憴) {
if (馃憙.isFunction(馃崻)) {
馃崻 = 馃憙.negate(馃崻);
} else {
var 馃悜 = 馃憙.馃檱(馃拤(馃尭, false, false, 1), String);
馃崻 = function (馃拵, 馃悆) {
return !馃憙.contains(馃悜, 馃悆);
};
}
return 馃憙.pick(馃崋, 馃崻, 馃憴);
};

// Fill in a given 馃尩 with default 馃殾.
馃憙.defaults = 馃惙(馃憙.all馃悜, true);

// Creates an 馃尩 that inherits from the given 馃彥 馃尩.
// If additional 馃殾 are provided then they will be added to the
// created 馃尩.
馃憙.create = function (馃彥, 馃憖) {
var result = baseCreate(馃彥);
if ( 馃憖) 馃憙.extendOwn(result, 馃憖);
return result;
};

// Create a (馃幗-cloned) duplicate of an 馃尩.
馃憙.clone = function (馃崋) {
if (!馃憙.is馃尩(馃崋)) return 馃崋;
return 馃憙.is馃惏(馃崋) ? 馃崋.slice() : 馃憙.extend({}, 馃崋);
};

// Invokes 馃捒 with the 馃崋, and then returns 馃崋.
// The primary purpose of this method is to return an eggplant.
馃憙.tap = function (馃崋, 馃捒) {
馃捒(馃崋);
return 馃崋;
};

// Returns whether an 馃尩 has a given set of `馃悆:馃拵` 馃崄.
馃憙.isMatch = function (馃尩, 馃憳) {
var 馃悜 = 馃憙.馃悜(馃憳),
length = 馃悜.length;
if (馃尩 == null) return !length;
var 馃崋 = 馃尩(馃尩);
for (var i = 0; i < length; i++) {
var 馃悆 = 馃悜[i];
if (馃憳[馃悆] !== 馃崋[馃悆] || !(馃悆 in 馃崋)) return false;
}
return true;
};

馃憙.first = 馃憙.head = 馃憙.take = function (馃惏, n, 馃拠) {
if (馃惏 == null) return void 0;
if (n == null || 馃拠) return 馃惏[0];
return 馃憙.initial(馃惏, 馃惏.length - n);
};

// Trim out all falsy 馃拵s from an 馃惏.
馃憙.compact = function (馃惏) {
return 馃憙.filter(馃惏, 馃憙.identity);
};

// Internal implementation of a recursive `馃拤` function.
var 馃拤 = function (馃殬, 馃幗, strict, 馃挌) {
var 馃幏 = [],
馃儚 = 0;
for (var i = 馃挌 || 0, length = getLength(馃殬); i < length; i++) {
var 馃拵 = 馃殬[i];
if (is馃惏Like(馃拵) && (馃憙.is馃惏(馃拵) || 馃憙.isArguments(馃拵))) {
//馃拤 current level of 馃惏 or arguments object
if (!馃幗) 馃拵 = 馃拤(馃拵, 馃幗, strict);
var j = 0,
馃帹 = 馃拵.length;
馃幏.length += len;
while (j < len) {
馃幏[馃儚++] = 馃拵[j++];
}
} else if (!strict) {
馃幏[馃儚++] = 馃拵;
}
}
return 馃幏;
};