type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
ArrowFunction |
(provider) => { provider.refreshBegin() } | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
ArrowFunction |
(data: T) => {
this.isLoading = false;
this.data = data;
this.providers.forEach((provider) => { provider.update(data) });
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
ArrowFunction |
(provider) => { provider.update(data) } | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
ArrowFunction |
() => {
this.loading = false;
this.data = data;
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
ClassDeclaration | /*
* The MIT License (MIT)
* Copyright (c) 2016 Heat Ledger Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* */
abstract class AbstractDataProvider<T> {
protected providers: Array<DataProvider<T>> = [];
protected data: T;
protected isLoading: boolean = false;
public createProvider($scope: angular.IScope) {
var provider = new DataProvider<T>($scope);
provider.data = this.getInitialData();
this.providers.push(provider);
$scope.$on('$destroy', () => { this.destroyProvider(provider) });
if (!this.isLoading) {
provider.update(this.data);
}
return provider;
}
private destroyProvider(provider: DataProvider<T>) {
this.providers = this.providers.filter((p) => p != provider);
}
abstract getData(): angular.IPromise<T>;
abstract getInitialData(): T;
protected refresh() {
this.providers.forEach((provider) => { provider.refreshBegin() });
this.isLoading = true;
this.getData().then((data: T) => {
this.isLoading = false;
this.data = data;
this.providers.forEach((provider) => { provider.update(data) });
});
}
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
ClassDeclaration |
class DataProvider<T> {
public data: T;
public loading: boolean = true;
constructor(private $scope: angular.IScope) {}
public update(data: T) {
this.$scope.$evalAsync(() => {
this.loading = false;
this.data = data;
});
}
public refreshBegin() {
this.loading = true;
this.$scope.$evalAsync(angular.noop);
}
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
MethodDeclaration |
public createProvider($scope: angular.IScope) {
var provider = new DataProvider<T>($scope);
provider.data = this.getInitialData();
this.providers.push(provider);
$scope.$on('$destroy', () => { this.destroyProvider(provider) });
if (!this.isLoading) {
provider.update(this.data);
}
return provider;
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
MethodDeclaration |
private destroyProvider(provider: DataProvider<T>) {
this.providers = this.providers.filter((p) => p != provider);
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
MethodDeclaration |
abstract getData(): angular.IPromise<T>; | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
MethodDeclaration |
abstract getInitialData(): T; | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
MethodDeclaration |
protected refresh() {
this.providers.forEach((provider) => { provider.refreshBegin() });
this.isLoading = true;
this.getData().then((data: T) => {
this.isLoading = false;
this.data = data;
this.providers.forEach((provider) => { provider.update(data) });
});
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
MethodDeclaration |
public update(data: T) {
this.$scope.$evalAsync(() => {
this.loading = false;
this.data = data;
});
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
MethodDeclaration |
public refreshBegin() {
this.loading = true;
this.$scope.$evalAsync(angular.noop);
} | Heat-Ledger-Ltd/heat-ui | app/src/services/AbstractDataProvider.ts | TypeScript |
ClassDeclaration |
export class Decoder {
private readonly decoder: SafeDecoder;
constructor(ua: ArrayBuffer) {
this.decoder = new SafeDecoder(ua);
}
isNextNil(): bool {
return this.decoder.isNextNil();
}
readBool(): bool {
return this.decoder.readBool().unwrap();
}
readInt8(): i8 {
return this.decoder.readInt8().unwrap();
}
readInt16(): i16 {
return this.decoder.readInt16().unwrap();
}
readInt32(): i32 {
return this.decoder.readInt32().unwrap();
}
readInt64(): i64 {
return this.decoder.readInt64().unwrap();
}
readUInt8(): u8 {
return this.decoder.readUInt8().unwrap();
}
readUInt16(): u16 {
return this.decoder.readUInt16().unwrap();
}
readUInt32(): u32 {
return this.decoder.readUInt32().unwrap();
}
readUInt64(): u64 {
return this.decoder.readUInt64().unwrap();
}
readFloat32(): f32 {
return this.decoder.readFloat32().unwrap();
}
readFloat64(): f64 {
return this.decoder.readFloat64().unwrap();
}
readString(): string {
return this.decoder.readString().unwrap();
}
readStringLength(): u32 {
return this.decoder.readStringLength().unwrap();
}
readBinLength(): u32 {
return this.decoder.readBinLength().unwrap();
}
readByteArray(): ArrayBuffer {
return this.decoder.readByteArray().unwrap();
}
readArraySize(): u32 {
return this.decoder.readArraySize().unwrap();
}
readMapSize(): u32 {
return this.decoder.readMapSize().unwrap();
}
readArray<T>(fn: (decoder: Decoder, i?: u32) => T): Array<T> {
const size = this.readArraySize();
let a = new Array<T>();
for (let i: u32 = 0; i < size; i++) {
const item = fn(this);
a.push(item);
}
return a;
}
readNullableArray<T>(fn: (decoder: Decoder, i?: u32) => T): Array<T> | null {
if (this.isNextNil()) {
return null;
}
return this.readArray(fn);
}
readMap<K, V>(keyFn: (decoder: Decoder, i?: u32) => K, valueFn: (decoder: Decoder, i?: u32) => V): Map<K, V> {
const size = this.readMapSize();
let m = new Map<K, V>();
for (let i: u32 = 0; i < size; i++) {
const key = keyFn(this, i);
const value = valueFn(this, i);
m.set(key, value);
}
return m;
}
readNullableMap<K, V>(keyFn: (decoder: Decoder, i?: u32) => K, valueFn: (decoder: Decoder, i?: u32) => V): Map<K, V> | null {
if (this.isNextNil()) {
return null;
}
return this.readMap(keyFn, valueFn);
}
isFloat32(u: u8): bool { return this.decoder.isFloat32(u); }
isFloat64(u: u8): bool { return this.decoder.isFloat64(u); }
isFixedInt(u: u8): bool { return this.decoder.isFixedInt(u); }
isNegativeFixedInt(u: u8): bool { return this.decoder.isNegativeFixedInt(u); }
isFixedMap(u: u8): bool { return this.decoder.isFixedMap(u); }
isFixedArray(u: u8): bool { return this.decoder.isFixedArray(u); }
isFixedString(u: u8): bool { return this.decoder.isFixedString(u); }
isNil(u: u8): bool { return this.decoder.isNil(u); }
getSize(): u32 { return this.decoder.getSize(); }
skip(): void { this.decoder.skip(); }
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isNextNil(): bool {
return this.decoder.isNextNil();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readBool(): bool {
return this.decoder.readBool().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt8(): i8 {
return this.decoder.readInt8().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt16(): i16 {
return this.decoder.readInt16().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt32(): i32 {
return this.decoder.readInt32().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt64(): i64 {
return this.decoder.readInt64().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt8(): u8 {
return this.decoder.readUInt8().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt16(): u16 {
return this.decoder.readUInt16().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt32(): u32 {
return this.decoder.readUInt32().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt64(): u64 {
return this.decoder.readUInt64().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readFloat32(): f32 {
return this.decoder.readFloat32().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readFloat64(): f64 {
return this.decoder.readFloat64().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readString(): string {
return this.decoder.readString().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readStringLength(): u32 {
return this.decoder.readStringLength().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readBinLength(): u32 {
return this.decoder.readBinLength().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readByteArray(): ArrayBuffer {
return this.decoder.readByteArray().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readArraySize(): u32 {
return this.decoder.readArraySize().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readMapSize(): u32 {
return this.decoder.readMapSize().unwrap();
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readArray<T>(fn: (decoder: Decoder, i?: u32) => T): Array<T> {
const size = this.readArraySize();
let a = new Array<T>();
for (let i: u32 = 0; i < size; i++) {
const item = fn(this);
a.push(item);
}
return a;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readNullableArray<T>(fn: (decoder: Decoder, i?: u32) => T): Array<T> | null {
if (this.isNextNil()) {
return null;
}
return this.readArray(fn);
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readMap<K, V>(keyFn: (decoder: Decoder, i?: u32) => K, valueFn: (decoder: Decoder, i?: u32) => V): Map<K, V> {
const size = this.readMapSize();
let m = new Map<K, V>();
for (let i: u32 = 0; i < size; i++) {
const key = keyFn(this, i);
const value = valueFn(this, i);
m.set(key, value);
}
return m;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readNullableMap<K, V>(keyFn: (decoder: Decoder, i?: u32) => K, valueFn: (decoder: Decoder, i?: u32) => V): Map<K, V> | null {
if (this.isNextNil()) {
return null;
}
return this.readMap(keyFn, valueFn);
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFloat32(u: u8): bool { return this.decoder.isFloat32(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFloat64(u: u8): bool { return this.decoder.isFloat64(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedInt(u: u8): bool { return this.decoder.isFixedInt(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isNegativeFixedInt(u: u8): bool { return this.decoder.isNegativeFixedInt(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedMap(u: u8): bool { return this.decoder.isFixedMap(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedArray(u: u8): bool { return this.decoder.isFixedArray(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedString(u: u8): bool { return this.decoder.isFixedString(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isNil(u: u8): bool { return this.decoder.isNil(u); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
getSize(): u32 { return this.decoder.getSize(); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
skip(): void { this.decoder.skip(); } | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isNextNil(): bool {
if (this.reader.peekUint8() == Format.NIL) {
this.reader.discard(1);
return true;
}
return false;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readBool(): Result<bool> {
const value = this.reader.getUint8();
if (value == Format.TRUE) {
return Result.ok<bool>(true);
} else if (value == Format.FALSE) {
return Result.ok<bool>(false);
}
return Result.err<bool>(new Error("bad value for bool: value = 0x" + value.toString(16) + "; type = " + formatName(value)));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt8(): Result<i8> {
const result = this.readInt64()
if (result.isErr) {
return Result.err<i8>(result.unwrapErr());
}
const value = result.unwrap();
if (value <= <i64>i8.MAX_VALUE && value >= <i64>i8.MIN_VALUE) {
return Result.ok<i8>(<i8>value);
}
return Result.err<i8>(new Error(
"integer overflow: value = " + value.toString() + "; bits = 8"
));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt16(): Result<i16> {
const result = this.readInt64()
if (result.isErr) {
return Result.err<i16>(result.unwrapErr());
}
const value = result.unwrap();
if (value <= <i64>i16.MAX_VALUE && value >= <i64>i16.MIN_VALUE) {
return Result.ok<i16>(<i16>value);
}
return Result.err<i16>(new Error(
"integer overflow: value = " + value.toString() + "; bits = 16"
));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt32(): Result<i32> {
const result = this.readInt64()
if (result.isErr) {
return Result.err<i32>(result.unwrapErr());
}
const value = result.unwrap();
if (value <= <i64>i32.MAX_VALUE && value >= <i64>i32.MIN_VALUE) {
return Result.ok<i32>(<i32>value);
}
return Result.err<i32>(new Error(
"integer overflow: value = " + value.toString() + "; bits = 32"
));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readInt64(): Result<i64> {
const prefix = this.reader.getUint8();
if (this.isFixedInt(prefix)) {
return Result.ok<i64>(<i64>prefix);
}
if (this.isNegativeFixedInt(prefix)) {
return Result.ok<i64>(<i64>(<i8>prefix));
}
switch (prefix) {
case Format.INT8:
return Result.ok<i64>(<i64>this.reader.getInt8());
case Format.INT16:
return Result.ok<i64>(<i64>this.reader.getInt16());
case Format.INT32:
return Result.ok<i64>(<i64>this.reader.getInt32());
case Format.INT64:
return Result.ok<i64>(this.reader.getInt64());
case Format.UINT8:
return Result.ok<i64>(<i64>this.reader.getUint8());
case Format.UINT16:
return Result.ok<i64>(<i64>this.reader.getUint16());
case Format.UINT32:
return Result.ok<i64>(<i64>this.reader.getUint32());
case Format.UINT64: {
const value = this.reader.getUint64();
if (value <= <u64>i64.MAX_VALUE) {
return Result.ok<i64>(<i64>value);
}
return Result.err<i64>(new Error(
"integer overflow: value = " + value.toString() + "; type = i64"
));
}
default:
return Result.err<i64>(new Error("bad prefix for int: prefix = 0x" + prefix.toString(16) + "; type = " + formatName(prefix)));
}
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt8(): Result<u8> {
const result = this.readUInt64()
if (result.isErr) {
return Result.err<u8>(result.unwrapErr());
}
const value = result.unwrap();
if (value <= <u64>u8.MAX_VALUE) {
return Result.ok<u8>(<u8>value);
}
return Result.err<u8>(new Error(
"unsigned integer overflow: value = " + value.toString() + "; bits = 8"
));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt16(): Result<u16> {
const result = this.readUInt64()
if (result.isErr) {
return Result.err<u16>(result.unwrapErr());
}
const value = result.unwrap();
if (value <= <u64>u16.MAX_VALUE) {
return Result.ok<u16>(<u16>value);
}
return Result.err<u16>(new Error(
"unsigned integer overflow: value = " + value.toString() + "; bits = 16"
));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt32(): Result<u32> {
const result = this.readUInt64()
if (result.isErr) {
return Result.err<u32>(result.unwrapErr());
}
const value = result.unwrap();
if (value <= <u64>u32.MAX_VALUE) {
return Result.ok<u32>(<u32>value);
}
return Result.err<u32>(new Error(
"unsigned integer overflow: value = " + value.toString() + "; bits = 32"
));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readUInt64(): Result<u64> {
const prefix = this.reader.getUint8();
if (this.isFixedInt(prefix)) {
return Result.ok<u64>(<u64>prefix);
} else if (this.isNegativeFixedInt(prefix)) {
return Result.err<u64>(new Error("bad prefix for unsigned int: prefix = 0x" + prefix.toString(16) + "; type = " + formatName(prefix)));
}
switch (prefix) {
case Format.UINT8:
return Result.ok<u64>(<u64>this.reader.getUint8());
case Format.UINT16:
return Result.ok<u64>(<u64>this.reader.getUint16());
case Format.UINT32:
return Result.ok<u64>(<u64>this.reader.getUint32());
case Format.UINT64:
return Result.ok<u64>(this.reader.getUint64());
case Format.INT8: {
const value = this.reader.getInt8();
if (value >= 0) {
return Result.ok<u64>(<u64>value);
}
return Result.err<u64>(new Error(
"integer underflow: value = " + value.toString() + "; type = u64"
));
}
case Format.INT16:
const value = this.reader.getInt16();
if (value >= 0) {
return Result.ok<u64>(<u64>value);
}
return Result.err<u64>(new Error(
"integer underflow: value = " + value.toString() + "; type = u64"
));
case Format.INT32:
const value = this.reader.getInt32();
if (value >= 0) {
return Result.ok<u64>(<u64>value);
}
return Result.err<u64>(new Error(
"integer underflow: value = " + value.toString() + "; type = u64"
));
case Format.INT64:
const value = this.reader.getInt64();
if (value >= 0) {
return Result.ok<u64>(<u64>value);
}
return Result.err<u64>(new Error(
"integer underflow: value = " + value.toString() + "; type = u64"
));
default:
return Result.err<u64>(new Error("bad prefix for unsigned int: prefix = 0x" + prefix.toString(16) + "; type = " + formatName(prefix)));
}
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readFloat32(): Result<f32> {
const prefix = this.reader.getUint8();
if (this.isFloat32(prefix)) {
return Result.ok<f32>(<f32>this.reader.getFloat32());
} else if (this.isFloat64(prefix)) {
const value = this.reader.getFloat64();
const diff = <f64>f32.MAX_VALUE - value;
if (abs(diff) <= <f64>f32.EPSILON) {
return Result.ok<f32>(f32.MAX_VALUE);
} else if (diff < 0) {
return Result.err<f32>(new Error(
"float overflow: value = " + value.toString() + "; type = f32"
));
} else {
return Result.ok<f32>(<f32>value);
}
} else {
return Result.err<f32>(new Error("bad prefix for float: prefix = 0x" + prefix.toString(16) + "; type = " + formatName(prefix)));
}
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readFloat64(): Result<f64> {
const prefix = this.reader.getUint8();
if (this.isFloat64(prefix)) {
return Result.ok<f64>(<f64>this.reader.getFloat64());
} else if (this.isFloat32(prefix)) {
return Result.ok<f64>(<f64>this.reader.getFloat32());
} else {
return Result.err<f64>(new Error("bad prefix for float: prefix = 0x" + prefix.toString(16) + "; type = " + formatName(prefix)));
}
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readString(): Result<string> {
const result = this.readStringLength();
if (result.isErr) {
return Result.err<string>(result.unwrapErr());
}
const strLen = result.unwrap();
const stringBytes = this.reader.getBytes(strLen);
return Result.ok<string>(String.UTF8.decode(stringBytes));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readStringLength(): Result<u32> {
const leadByte = this.reader.getUint8();
if (this.isFixedString(leadByte)) {
return Result.ok<u32>(leadByte & 0x1f);
}
if (this.isFixedArray(leadByte)) {
return Result.ok<u32>(<u32>(leadByte & Format.FOUR_LEAST_SIG_BITS_IN_BYTE));
}
switch (leadByte) {
case Format.STR8:
return Result.ok<u32>(<u32>this.reader.getUint8());
case Format.STR16:
return Result.ok<u32>(<u32>this.reader.getUint16());
case Format.STR32:
return Result.ok<u32>(this.reader.getUint32());
}
return Result.err<u32>(new RangeError(E_INVALIDLENGTH + ": prefix = 0x" + leadByte.toString(16) + "; type = " + formatName(leadByte)));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readBinLength(): Result<u32> {
if (this.isNextNil()) {
return Result.ok<u32>(0);
}
const leadByte = this.reader.getUint8();
if (this.isFixedArray(leadByte)) {
return Result.ok<u32>(<u32>(leadByte & Format.FOUR_LEAST_SIG_BITS_IN_BYTE));
}
switch (leadByte) {
case Format.BIN8:
return Result.ok<u32>(<u32>this.reader.getUint8());
case Format.BIN16:
return Result.ok<u32>(<u32>this.reader.getUint16());
case Format.BIN32:
return Result.ok<u32>(this.reader.getUint32());
}
return Result.err<u32>(new RangeError(E_INVALIDLENGTH + ": prefix = 0x" + leadByte.toString(16) + "; type = " + formatName(leadByte)));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readByteArray(): Result<ArrayBuffer> {
const result = this.readBinLength();
if (result.isErr) {
return Result.err<ArrayBuffer>(result.unwrapErr());
}
const arrLength = result.unwrap();
const arrBytes = this.reader.getBytes(arrLength);
return Result.ok<ArrayBuffer>(arrBytes);
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readArraySize(): Result<u32> {
const leadByte = this.reader.getUint8();
if (this.isFixedArray(leadByte)) {
return Result.ok<u32>(<u32>(leadByte & Format.FOUR_LEAST_SIG_BITS_IN_BYTE));
} else if (leadByte == Format.ARRAY16) {
return Result.ok<u32>(<u32>this.reader.getUint16());
} else if (leadByte == Format.ARRAY32) {
return Result.ok<u32>(this.reader.getUint32());
} else if (leadByte == Format.NIL) {
return Result.ok<u32>(0);
}
return Result.err<u32>(new RangeError(E_INVALIDLENGTH + ": prefix = 0x" + leadByte.toString(16) + "; type = " + formatName(leadByte)));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readMapSize(): Result<u32> {
const leadByte = this.reader.getUint8();
if (this.isFixedMap(leadByte)) {
return Result.ok<u32>(<u32>(leadByte & Format.FOUR_LEAST_SIG_BITS_IN_BYTE));
} else if (leadByte == Format.MAP16) {
return Result.ok<u32>(<u32>this.reader.getUint16());
} else if (leadByte == Format.MAP32) {
return Result.ok<u32>(this.reader.getUint32());
}
return Result.err<u32>(new RangeError(E_INVALIDLENGTH + ": prefix = 0x" + leadByte.toString(16) + "; type = " + formatName(leadByte)));
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFloat32(u: u8): bool {
return u == Format.FLOAT32;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFloat64(u: u8): bool {
return u == Format.FLOAT64;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedInt(u: u8): bool {
return u >> 7 == 0;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isNegativeFixedInt(u: u8): bool {
return (u & 0xe0) == Format.NEGATIVE_FIXINT;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedMap(u: u8): bool {
return (u & 0xf0) == Format.FIXMAP;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedArray(u: u8): bool {
return (u & 0xf0) == Format.FIXARRAY;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isFixedString(u: u8): bool {
return (u & 0xe0) == Format.FIXSTR;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
isNil(u: u8): bool {
return u == Format.NIL;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
skip(): void {
// getSize handles discarding 'msgpack header' info
let numberOfObjectsToDiscard = this.getSize();
while (numberOfObjectsToDiscard > 0) {
this.skip(); // discard next object
numberOfObjectsToDiscard--;
}
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
getSize(): i32 {
const leadByte = this.reader.getUint8(); // will discard one
let objectsToDiscard = <i32>0;
// Handled for fixed values
if (this.isNegativeFixedInt(leadByte)) {
// noop, will just discard the leadbyte
} else if (this.isFixedInt(leadByte)) {
// noop, will just discard the leadbyte
} else if (this.isFixedString(leadByte)) {
let strLength = leadByte & 0x1f;
this.reader.discard(strLength);
} else if (this.isFixedArray(leadByte)) {
// TODO handle overflow
objectsToDiscard = <i32>(leadByte & Format.FOUR_LEAST_SIG_BITS_IN_BYTE);
} else if (this.isFixedMap(leadByte)) {
// TODO handle overflow
objectsToDiscard =
2 * <i32>(leadByte & Format.FOUR_LEAST_SIG_BITS_IN_BYTE);
} else {
switch (leadByte) {
case Format.NIL:
break;
case Format.TRUE:
break;
case Format.FALSE:
break;
case Format.BIN8:
this.reader.discard(<i32>this.reader.getUint8());
break;
case Format.BIN16:
this.reader.discard(<i32>this.reader.getUint16());
break;
case Format.BIN32:
this.reader.discard(<i32>this.reader.getUint32());
break;
case Format.FLOAT32:
this.reader.discard(4);
break;
case Format.FLOAT64:
this.reader.discard(8);
break;
case Format.UINT8:
this.reader.discard(1);
break;
case Format.UINT16:
this.reader.discard(2);
break;
case Format.UINT32:
this.reader.discard(4);
break;
case Format.UINT64:
this.reader.discard(8);
break;
case Format.INT8:
this.reader.discard(1);
break;
case Format.INT16:
this.reader.discard(2);
break;
case Format.INT32:
this.reader.discard(4);
break;
case Format.INT64:
this.reader.discard(8);
break;
case Format.FIXEXT1:
this.reader.discard(2);
break;
case Format.FIXEXT2:
this.reader.discard(3);
break;
case Format.FIXEXT4:
this.reader.discard(5);
break;
case Format.FIXEXT8:
this.reader.discard(9);
break;
case Format.FIXEXT16:
this.reader.discard(17);
break;
case Format.STR8:
this.reader.discard(this.reader.getUint8());
break;
case Format.STR16:
this.reader.discard(this.reader.getUint16());
break;
case Format.STR32:
// TODO overflow, need to modify discard and underlying array buffer
this.reader.discard(this.reader.getUint32());
break;
case Format.ARRAY16:
//TODO OVERFLOW
objectsToDiscard = <i32>this.reader.getUint16();
break;
case Format.ARRAY32:
//TODO OVERFLOW
objectsToDiscard = <i32>this.reader.getUint32();
break;
case Format.MAP16:
//TODO OVERFLOW
objectsToDiscard = 2 * <i32>this.reader.getUint16();
break;
case Format.MAP32:
//TODO OVERFLOW
objectsToDiscard = 2 * <i32>this.reader.getUint32();
break;
default:
throw new TypeError(
"invalid prefix, bad encoding for val: " + leadByte.toString()
);
}
}
return objectsToDiscard;
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readArray<T>(fn: (decoder: SafeDecoder, i?: u32) => Result<T>): Result<Array<T>> {
const result = this.readArraySize();
if (result.isErr) {
return Result.err<Array<T>>(result.unwrapErr());
}
const size = result.unwrap();
let a = new Array<T>();
for (let i: u32 = 0; i < size; i++) {
const itemResult = fn(this, i);
if (itemResult.isErr) {
return Result.err<Array<T>>(itemResult.unwrapErr());
}
a.push(itemResult.unwrap());
}
return Result.ok<Array<T>>(a);
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readNullableArray<T>(fn: (decoder: SafeDecoder, i?: u32) => Result<T>): Result<Array<T> | null> {
if (this.isNextNil()) {
return Result.ok<Array<T> | null>(null);
}
const result = this.readArray(fn);
if (result.isOk) {
return Result.ok<Array<T> | null>(result.unwrap());
} else {
return Result.err<Array<T> | null>(result.unwrapErr());
}
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readMap<K, V>(
keyFn: (decoder: SafeDecoder, i?: u32) => Result<K>,
valueFn: (decoder: SafeDecoder, i?: u32) => Result<V>
): Result<Map<K, V>> {
const result = this.readMapSize();
if (result.isErr) {
return Result.err<Map<K, V>>(result.unwrapErr());
}
const size = result.unwrap();
let m = new Map<K, V>();
for (let i: u32 = 0; i < size; i++) {
const keyResult = keyFn(this, i);
if (keyResult.isErr) {
return Result.err<Map<K, V>>(keyResult.unwrapErr());
}
const valueResult = valueFn(this, i);
if (valueResult.isErr) {
return Result.err<Map<K, V>>(valueResult.unwrapErr());
}
m.set(keyResult.unwrap(), valueResult.unwrap());
}
return Result.ok<Map<K, V>>(m);
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
MethodDeclaration |
readNullableMap<K, V>(
keyFn: (decoder: SafeDecoder, i?: u32) => Result<K>,
valueFn: (decoder: SafeDecoder, i?: u32) => Result<V>
): Result<Map<K, V> | null> {
if (this.isNextNil()) {
return Result.ok<Map<K, V> | null>(null);
}
const result = this.readMap(keyFn, valueFn);
if (result.isOk) {
return Result.ok<Map<K, V> | null>(result.unwrap());
} else {
return Result.err<Map<K, V> | null>(result.unwrapErr());
}
} | Shopify/as-msgpack | assembly/decoder.ts | TypeScript |
FunctionDeclaration | // function must flip integer numbers
// O(n)
function reverseInteger(integer: number): number {
const reversedInt = Number(
integer.toString().replace('-', '').split('').reverse().join('')
);
return Math.sign(integer) * reversedInt;
} | FairlyTales/Algorithms_in_JavaScript | string_manipulation_algorithms/reverseInteger.ts | TypeScript |
ClassDeclaration |
@Injectable({
providedIn: 'root'
})
export class ProveedorService {
private url:string;
constructor(private http: HttpClient)
{
this.url = "https://demo.evdapps.com/api/proveedor";
}
getData(): Observable<Proveedor[]> {
return this.http.get<Proveedor[]>(this.url);
}
} | javc16/MWSFrontEnd | src/app/Servicios/Proveedor/proveedor.service.ts | TypeScript |
MethodDeclaration |
getData(): Observable<Proveedor[]> {
return this.http.get<Proveedor[]>(this.url);
} | javc16/MWSFrontEnd | src/app/Servicios/Proveedor/proveedor.service.ts | TypeScript |
FunctionDeclaration |
export function RadioGroup(props: RadioGroupProps) {
return (
<StyledRadioGroup className={props.className}>
<label htmlFor={props.id}>{props.label}</label>
<div>{props.children}</div>
</StyledRadioGroup>
);
} | syslaudo/syslaudo-frontend | src/components/FormComponents/RadioGroup/index.tsx | TypeScript |
InterfaceDeclaration |
interface RadioGroupProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
label: string;
} | syslaudo/syslaudo-frontend | src/components/FormComponents/RadioGroup/index.tsx | TypeScript |
ClassDeclaration | /**
* Represents a bb-code.
*/
export class BBCode
{
/**
* The name of the bb-code.
*/
private name: string;
/**
* The human-readable name of the bb-code.
*/
private displayName: Localization = new Localization();
/**
* The name of a font-awesome icon for the bb-code-button.
*/
private icon: string = null;
/**
* The class-name of the bb-code.
*/
private className: string = null;
/**
* The name of the HTML-tag.
*/
private tagName: string = null;
/**
* A value indicating whether the HTML-tag is self-closing.
*/
private isSelfClosing = false;
/**
* A value indicating whether the bb-code is a block-element.
*/
private isBlockElement = true;
/**
* A value indicating whether the content of the bb-code should be parsed.
*/
private parseContent = false;
/**
* The attributes of the bb-code.
*/
private attributes: BBCodeAttribute[] = [];
/**
* Initializes a new instance of the {@link BBCode `BBCode`} class.
*
* @param options
* The options of the bbcode.
*/
public constructor(options: IBBCodeOptions)
{
this.Name = options.Name;
if (
(options.DisplayName !== null) &&
(options.DisplayName !== undefined))
{
this.DisplayName.Load(options.DisplayName);
}
if (
(options.Icon !== null) &&
(options.Icon !== undefined))
{
this.Icon = options.Icon;
}
if (
(options.ClassName !== null) &&
(options.ClassName !== undefined))
{
this.ClassName = options.ClassName;
}
if (
(options.TagName !== null) &&
(options.TagName !== undefined))
{
this.TagName = options.TagName;
}
if (
(options.IsSelfClosing !== null) &&
(options.IsSelfClosing !== undefined))
{
this.IsSelfClosing = options.IsSelfClosing;
}
if (
(options.IsBlockElement !== null) &&
(options.IsBlockElement !== undefined))
{
this.IsBlockElement = options.IsBlockElement;
}
if (
(options.ParseContent !== null) &&
(options.ParseContent !== undefined))
{
this.ParseContent = options.ParseContent;
}
if (
(options.Attributes !== null) &&
(options.Attributes !== undefined))
{
for (let attribute of options.Attributes)
{
this.Attributes.push(new BBCodeAttribute(attribute));
}
}
}
/**
* Gets or sets the name of the bb-code.
*/
public get Name(): string
{
return this.name;
}
/**
* @inheritdoc
*/
public set Name(value: string)
{
this.name = value;
}
/**
* Gets the human-readable name of the bb-code.
*/
public get DisplayName(): Localization
{
return this.displayName;
}
/**
* Gets or sets the name of a font-awesome icon for the bb-code-button.
*/
public get Icon(): string
{
return this.icon;
}
/**
* @inheritdoc
*/
public set Icon(value: string)
{
this.icon = value;
}
/**
* Gets or sets the class-name of the bb-code.
*/
public get ClassName(): string
{
return this.className;
}
/**
* @inheritdoc
*/
public set ClassName(value: string)
{
this.className = value;
}
/**
* Gets or sets the name of the HTML-tag.
*/
public get TagName(): string
{
return this.tagName;
}
/**
* @inheritdoc
*/
public set TagName(value: string)
{
this.tagName = value;
}
/**
* Gets or sets a value indicating whether the HTML-tag is self-closing.
*/
public get IsSelfClosing(): boolean
{
return this.isSelfClosing;
}
/**
* @inheritdoc
*/
public set IsSelfClosing(value: boolean)
{
this.isSelfClosing = value;
}
/**
* Gets or sets a value indicating whether the bb-code is a block-element.
*/
public get IsBlockElement(): boolean
{
return this.isBlockElement;
}
/**
* @inheritdoc
*/
public set IsBlockElement(value: boolean)
{
this.isBlockElement = value;
}
/**
* Gets or sets a value indicating whether the content of the bb-code should be parsed.
*/
public get ParseContent(): boolean
{
return this.parseContent;
}
/**
* @inheritdoc
*/
public set ParseContent(value: boolean)
{
this.parseContent = value;
}
/**
* Gets the attributes of the bb-code.
*/
public get Attributes(): BBCodeAttribute[]
{
return this.attributes;
}
} | manuth/WoltLabCompiler | src/Customization/BBCodes/BBCode.ts | TypeScript |
FunctionDeclaration | /**
* Returns the AvailabilityPercentage for NodeAtomic nodes
* @param {string} guildName
* @param {string} endpointUrl
* @return {Promise<unknown>}
*/
export async function getAvailabilityNodeAtomic(guildName: string, endpointUrl: string): Promise<unknown> {
const param = [guildName, endpointUrl];
const entityManager = getManager();
return await entityManager.query(
`
with successCount(validation_date, count) as (
select date(validation_date), count(all_checks_ok)
from node_atomic
where guild = $1 and endpoint_url = $2
and all_checks_ok='4'
group by date(validation_date)),
totalCount(validation_date, count) as (
select date(validation_date), count(all_checks_ok)
from node_atomic
where guild = $1 and endpoint_url = $2
group by date(validation_date))
select totalCount.validation_date as date, (coalesce(successCount.count, 0) * 100 / coalesce(totalCount.count, 1)) as availability
from successCount
full outer join totalCount
on successCount.validation_date = totalCount.validation_date
order by date asc;
`,
param
);
} | Blacklusion/validationcore-api | src/datasources/postgres/queries/availability/getAvailabilityNodeAtomic.ts | TypeScript |
FunctionDeclaration |
function levelsToQuery(levels: string[]): string {
return levels
.sort()
.map((key) => key.toLowerCase())
.join(DELIMITER);
} | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
FunctionDeclaration |
export function encodeRunPageFilters(filter: LogFilter) {
const logQueryTokenStrings = filter.logQuery.map((v) =>
v.token ? `${v.token}:${v.value}` : v.value,
);
return {
hideNonMatches: filter.hideNonMatches ? 'true' : 'false',
focusedTime: filter.focusedTime || '',
logs: logQueryTokenStrings.join(DELIMITER),
levels: levelsToQuery(Object.keys(filter.levels).filter((key) => !!filter.levels[key])),
};
} | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
FunctionDeclaration |
export function useQueryPersistedLogFilter() {
return useQueryPersistedState<LogFilter>({
encode: encodeRunPageFilters,
decode: decodeRunPageFilters,
defaults: DefaultQuerystring,
});
} | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(key) => key.toLowerCase() | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(qs: {[key: string]: string}) => {
const logValues = qs['logs'].split(DELIMITER);
const focusedTime = qs['focusedTime'] && !qs['logs'] ? Number(qs['focusedTime']) : null;
const hideNonMatches = qs['hideNonMatches'] === 'true' ? true : false;
const providers = getRunFilterProviders();
const logQuery = logValues.map((token) => tokenizedValueFromString(token, providers));
const levelsValues = qs['levels'].split(DELIMITER);
return {
sinceTime: 0,
focusedTime,
hideNonMatches,
logQuery,
levels: levelsValues
.map((level) => level.toUpperCase())
.filter((level) => LogLevel.hasOwnProperty(level))
.reduce((accum, level) => ({...accum, [level]: true}), {}),
} as LogFilter;
} | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(token) => tokenizedValueFromString(token, providers) | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(level) => level.toUpperCase() | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(level) => LogLevel.hasOwnProperty(level) | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(accum, level) => ({...accum, [level]: true}) | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(v) =>
v.token ? `${v.token}:${v.value}` : v.value | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
(key) => !!filter.levels[key] | Kapernikov/dagster | js_modules/dagit/packages/core/src/runs/useQueryPersistedLogFilter.ts | TypeScript |
ArrowFunction |
() => {
let component: ImagesComponent;
let fixture: ComponentFixture<ImagesComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ImagesComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ImagesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
} | Dima2022/DiscountsApp | SCNDISC.FrontEnd/SCNDISC.Admin.UI/src/app/partner/components/images/images.component.spec.ts | TypeScript |
ArrowFunction |
() => {
TestBed.configureTestingModule({
declarations: [ ImagesComponent ]
})
.compileComponents();
} | Dima2022/DiscountsApp | SCNDISC.FrontEnd/SCNDISC.Admin.UI/src/app/partner/components/images/images.component.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture = TestBed.createComponent(ImagesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
} | Dima2022/DiscountsApp | SCNDISC.FrontEnd/SCNDISC.Admin.UI/src/app/partner/components/images/images.component.spec.ts | TypeScript |
ClassDeclaration |
export declare class ListOpsItemEventsCommand extends $Command<ListOpsItemEventsCommandInput, ListOpsItemEventsCommandOutput, SSMClientResolvedConfig> {
readonly input: ListOpsItemEventsCommandInput;
constructor(input: ListOpsItemEventsCommandInput);
resolveMiddleware(clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, configuration: SSMClientResolvedConfig, options?: __HttpHandlerOptions): Handler<ListOpsItemEventsCommandInput, ListOpsItemEventsCommandOutput>;
private serialize;
private deserialize;
} | dwardu89/aws-ssm-parameter-store | node_modules/@aws-sdk/client-ssm/dist-types/ts3.4/commands/ListOpsItemEventsCommand.d.ts | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.