mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Update to fbjs@0.3
As far as we're concerned, the only difference is that we moved some files from React to fbjs.
This commit is contained in:
1 parent
4fa3ce48e8
commit
693dd3567b
6 files changed
+2
-152
No files matched your search
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails react-core
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('memoizeStringOnly', function() {
|
||||
var memoizeStringOnly;
|
||||
|
||||
beforeEach(function() {
|
||||
require('mock-modules').dumpCache();
|
||||
memoizeStringOnly = require('memoizeStringOnly');
|
||||
});
|
||||
|
||||
it('should be transparent to callers', function() {
|
||||
var callback = function(string) {
|
||||
return string;
|
||||
};
|
||||
var memoized = memoizeStringOnly(callback);
|
||||
|
||||
expect(memoized('foo'), callback('foo'));
|
||||
});
|
||||
});
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule memoizeStringOnly
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Memoizes the return value of a function that accepts one string argument.
|
||||
*
|
||||
* @param {function} callback
|
||||
* @return {function}
|
||||
*/
|
||||
function memoizeStringOnly(callback) {
|
||||
var cache = {};
|
||||
return function(string) {
|
||||
if (!cache.hasOwnProperty(string)) {
|
||||
cache[string] = callback.call(this, string);
|
||||
}
|
||||
return cache[string];
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = memoizeStringOnly;
|
||||
Reference in new issue
Block a user