Rename Meteor.id() -> Random.id()

This commit is contained in:
David Glasser
2013-02-12 23:44:04 -08:00
parent fdb1773d4a
commit eb14cfceeb
7 changed files with 11 additions and 7 deletions

View File

@@ -684,7 +684,7 @@ Template.api.cursor_observe_changes = {
Template.api.id = {
id: "meteor_id",
name: "Meteor.id()",
name: "Random.id()",
locus: "Anywhere",
descr: ["Return a unique identifier."],
args: [ ]

View File

@@ -151,7 +151,7 @@ var toc = [
{instance: "cursor", name: "observeChanges", id: "observe_changes"}
],
{type: "spacer"},
"Meteor.id",
"Random.id", // XXX move this to the packages section
{name: "Meteor.Collection.ObjectID", id: "collection_object_id"},
{type: "spacer"},
{name: "Selectors", style: "noncode"},

View File

@@ -772,7 +772,7 @@ Meteor._LivedataSubscription = function (
if (self._subscriptionId) {
self._subscriptionHandle = 'N' + self._subscriptionId;
} else {
self._subscriptionHandle = 'U' + Meteor.id();
self._subscriptionHandle = 'U' + Random.id();
}
// has _deactivate been called?

View File

@@ -244,7 +244,7 @@ if (Meteor.isServer) {
// First add a random item, which should be cleaned up. We use ready/onReady
// to make sure that the second test block is only called after the added is
// processed, so that there's any chance of the coll.find().count() failing.
sub.added(collName, Meteor.id(), {foo: 42});
sub.added(collName, Random.id(), {foo: 42});
sub.ready();
if (options.stopInHandler) {

View File

@@ -436,7 +436,7 @@ if (Meteor.isClient) {
// conn._subscriptions is empty.
var conn = new Meteor._LivedataConnection('/',
{reloadWithOutstanding: true});
var collName = Meteor.id();
var collName = Random.id();
var coll = new Meteor.Collection(collName, {manager: conn});
var errorFromRerun;
var gotErrorFromStopper = false;

View File

@@ -2,7 +2,7 @@
var makeCollection = function () {
if (Meteor.isServer)
return new Meteor.Collection(Meteor.id());
return new Meteor.Collection(Random.id());
else
return new Meteor.Collection(null);
};

View File

@@ -1,3 +1,5 @@
// XXX update these comments
// XXX dups packages/minimongo/uuid.js
// Meteor.random() -- known good PRNG, replaces Math.random()
@@ -29,6 +31,8 @@
// SOFTWARE.
(function() {
Random = {};
var HEX_DIGITS = "0123456789abcdef";
var UNMISTAKABLE_CHARS = "23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz";
@@ -148,7 +152,7 @@ Meteor.uuid = function () {
return uuid;
};
Meteor.id = function() {
Random.id = function() {
var digits = [];
var base = UNMISTAKABLE_CHARS.length;
// Length of 17 preserves around 96 bits of entropy, which is the