const addFileDataIfNeeded = async file => { if (file._source.format === 'uri') { const base64 = await downloadFileFromURI(file._source.uri); file._previousSave = file; file._data = base64; file._requestTask = null; } return file; }
const getFragmentAssetUris = (refs, assetSize) => { const scriptUris = []; const styleUris = []; for (const ref of refs) { if (ref.rel === 'fragment-script') { scriptUris.push(ref.uri); } else if (ref.rel === 'stylesheet') { styleUris.push(ref.uri); } } return [scriptUris.slice(0, assetSize), styleUris.slice(0, assetSize)]; }
function formatData(obj) { return Object.keys(obj).map(function(key) { var user = obj[key]; return { alternateName: user.alternateName, firstName: user.firstName, gender: GENDERS[user.gender], userID: utils.formatID(user.id.toString()), isFriend: user.is_friend != null && user.is_friend ? true : false, fullName: user.name, profilePicture: user.thumbSrc, type: user.type, profileUrl: user.uri, vanity: user.vanity, isBirthday: !!user.is_birthday }; }); }
describe('#getFileStream', function getFileStreamSuite() { this.timeout(timeout); before(function before() { // utils.handleRatelimit(bot, 'getFileStream', this); }); it('should get a file stream', function test(done) { const fileStream = bot.getFileStream(FILE_ID); assert.ok(fileStream instanceof stream.Readable); assert.equal(fileStream.path, FILE_ID); fileStream.on('info', (info) => { assert.ok(info); assert.ok(utils.isTelegramFileURI(info.uri), `${info.uri} is not a file URI`); fileStream.pipe(concat(function readFile(buffer) { buffer.equals(fs.readFileSync(FILE_PATH)); // sync :( return done(); })); }); }); });
function parseOptions(options) { if (typeof options === 'string') { options = parseUrl(fullUrl); } else { var fullUrl = options.url || options.uri; if (fullUrl && typeof fullUrl === 'string') { options = extend(options, parseUrl(fullUrl)); } } var maxLength = options.maxLength; if (!(maxLength > 0)) { options.maxLength = 0; } options.agent = false; options.rejectUnauthorized = false; return options; }
export default function safeImagePropertiesForWidth( maxWidth ) { return function safeImageProperties( post ) { makeImageURLSafe( post.author, 'avatar_URL', maxWidth ); makeImageURLSafe( post, 'featured_image', maxWidth, post.URL ); if ( post.post_thumbnail ) { makeImageURLSafe( post.post_thumbnail, 'URL', maxWidth, post.URL ); } if ( post.featured_media && post.featured_media.type === 'image' ) { makeImageURLSafe( post.featured_media, 'uri', maxWidth, post.URL ); } if ( post.canonical_image && post.canonical_image.uri ) { makeImageURLSafe( post.canonical_image, 'uri', maxWidth, post.URL ); } if ( post.attachments ) { forOwn( post.attachments, function ( attachment ) { if ( startsWith( attachment.mime_type, 'image/' ) ) { makeImageURLSafe( attachment, 'URL', maxWidth, post.URL ); } } ); } return post; }; }
function formatData(data) { var retObj = {}; for (var prop in data) { if (data.hasOwnProperty(prop)) { var innerObj = data[prop]; retObj[prop] = { name: innerObj.name, firstName: innerObj.firstName, vanity: innerObj.vanity, thumbSrc: innerObj.thumbSrc, profileUrl: innerObj.uri, gender: innerObj.gender, type: innerObj.type, isFriend: innerObj.is_friend, isBirthday: !!innerObj.is_birthday }; } } return retObj; }
if (!factoryConfig.uri && !factoryConfig.create) { throw new Error(`Uri for factory "${factory}" is not defined. Please set "uri" parameter: if (!factoryConfig.create) factoryConfig.create = { post: factoryConfig.uri }; if (!factoryConfig.delete) factoryConfig.delete = { delete: `${factoryConfig.uri}/{id}` };
width: fetchData.image_with_metadata && fetchData.image_with_metadata.original_dimensions.x, height: fetchData.image_with_metadata && fetchData.image_with_metadata.original_dimensions.y, url: fetchData.image_with_metadata && fetchData.image_with_metadata.preview.uri
let model = monaco.editor .getModels() .find(model => model.uri.path === path);
.then(r => r.json()) .then(res => { if (res.uri === masto_domain) {
unreadCount: t.unread_count, messageCount: t.messages_count, imageSrc: t.image?t.image.uri:null, emoji: t.customization_info?t.customization_info.emoji:null, color: formatColor(t.customization_info?t.customization_info.outgoing_bubble_color:null),
url: options.uri, headers: options.headers, responseType: 'arraybuffer',
headers = uri.headers; method = typeof uri.method === 'string' ? uri.method : null; uri = uri.uri || uri.url || uri.href || curUrl; } else { if (type === 'function') {