<span className='offset'>{this.getGridRowOffset(row)}</span> _.map(dataSet, (l, idx) => <span className={getClazz('offset-pos', true, idx)}>{toHexString(l)}</span>)
describe("Test rule: objectID", () => { it("should validate ObjectID", () => { const rule: RuleObjectID = { type: "objectID", ObjectID }; const check = v.compile({ id: { type: "objectID", ObjectID } }); const message = "The 'id' field must be an valid ObjectID"; expect(check({ id: "5f082780b00cc7401fb8"})).toEqual([{ type: "objectID", field: "id", actual: "5f082780b00cc7401fb8", message }]); expect(check({ id: new ObjectID() })).toEqual(true); const o = { id: "5f082780b00cc7401fb8e8fc" }; expect(check(o)).toEqual(true); expect(o.id).toBe("5f082780b00cc7401fb8e8fc"); }); it("should convert hexString-objectID to ObjectID", () => { const check = v.compile({ id: { type: "objectID", ObjectID, convert: true } }); const oid = new ObjectID(); const o = { id: oid.toHexString() }; expect(check(o)).toEqual(true); expect(o.id).toBeInstanceOf(ObjectID); expect(o.id).toEqual(oid); }); });
const check = v.compile({ id: { type: "objectID", ObjectID, convert: true } }); const oid = new ObjectID(); const o = { id: oid.toHexString() };
_(tokens.props) .filter({ category: 'colors', type: 'color' }) .keyBy('name') .mapValues('value') .mapKeys((value, key) => _.kebabCase(key).replace('color-', '')) .mapValues(value => tinycolor(value).toHexString()) .value()
var did_i_follow = function(users, followers) { var followed_users_ids = _.map(followers, function(item) { return item.target.toHexString(); }); _.each(users, function(user) { if (followed_users_ids.indexOf(user._id.toHexString()) !== -1) { user.followed = true; } }); }
async componentDidMount() { const key = localStorage.getItem('mintPK'); if (!key) { return; } const keyPair = nacl.sign.keyPair.fromSecretKey(encoding.hex2ab(key)); const publicKey = encoding.toHexString(keyPair.publicKey).toUpperCase(); const user = await ajaxUtils.loadUser(publicKey); this.setState({ user }, () => { user && this.getUpvoteStatus(); }); }
tips.forEach(tip => { const deltaHash = cryptography.hash(tip.data); const hexAddr = DbUtils.toHexString(tip.address); logger.info(`address: ${hexAddr} => key: ${tip.key} hash: ${deltaHash}`); });
static getKeccak256FromCID(cid) { try { return multihash.toHexString(cid.multihash); } catch (err) { return null; } }
function generateHexAddress() { let byteAddr = []; for (let i = 0; i < ADDR_SIZE; ++i) { byteAddr.push(getRandomInt(255)); } return DbUtil.toHexString(byteAddr); }
test('should call next with no errors if user does not have required rights but userId is in params', async () => { await insertUsers([userOne]); const req = httpMocks.createRequest({ headers: { Authorization: `Bearer ${userOneAccessToken}` }, params: { userId: userOne._id.toHexString() }, }); const next = jest.fn(); await auth('anyRight')(req, httpMocks.createResponse(), next); expect(next).toHaveBeenCalledWith(); });
describe('user.generateAuthToken', () => { test('Should return a valid JWT', () => { const payload = { _id: new mongoose.Types.ObjectId().toHexString() }; const user = new User(payload); const token = user.generateAuthToken(); const decoded = jwt.verify(token, config.get('jwtPrivateKey')); expect(decoded).toMatchObject(payload); }); });
function getColorObject(value, name) { var c = tinycolor(value); return { name: name, hex: c.toHexString(), darkContrast: c.isLight() } }
async componentDidMount() { const key = localStorage.getItem('mintPK'); if (!key) { return; } const secret = encoding.hex2ab(key); const publicKey = encoding.toHexString(nacl.sign.keyPair.fromSecretKey(secret).publicKey).toUpperCase(); const user = await ajaxUtils.loadUser(publicKey); this.setState({ user }); }
tips.forEach(tip => { const deltaHash = cryptography.hash(tip.data); const hexAddr = DbUtils.toHexString(tip.address); logger.info(`address: ${hexAddr} => key: ${tip.key} hash: ${deltaHash}`); });
_(tokens.props) .filter({ category: 'colors', type: 'color' }) .keyBy('name') .mapValues('value') .mapKeys((value, key) => _.kebabCase(key).replace('color-', '')) .mapValues(value => tinycolor(value).toHexString()) .value()