isSequence
This commit is contained in:
parent
a8d7fda89e
commit
340f809c55
|
@ -6,3 +6,7 @@ export function isCompound<T = GenericEmbedded>(x: Value<T>): x is Compound<T>
|
|||
{
|
||||
return (Array.isArray(x) || Set.isSet(x) || Dictionary.isDictionary(x));
|
||||
}
|
||||
|
||||
export function isSequence<T = GenericEmbedded>(x: Value<T>): x is Array<Value<T>> {
|
||||
return (Array.isArray(x) && !('label' in x));
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ function converterForTuple(ctx: FunctionContext,
|
|||
|
||||
return knownArray
|
||||
? loop(0)
|
||||
: [seq(`if (_.Array.isArray(${src})`, lengthCheck, `) `, ctx.block(() => loop(0)))];
|
||||
: [seq(`if (_.isSequence(${src})`, lengthCheck, `) `, ctx.block(() => loop(0)))];
|
||||
}
|
||||
|
||||
function converterFor(
|
||||
|
@ -157,7 +157,7 @@ export function converterForSimple(
|
|||
return kKnownArray();
|
||||
} else {
|
||||
return [`${dest} = void 0`,
|
||||
seq(`if (_.Array.isArray(${src})) `, ctx.block(kKnownArray))];
|
||||
seq(`if (_.isSequence(${src})) `, ctx.block(kKnownArray))];
|
||||
}
|
||||
}
|
||||
case 'setof':
|
||||
|
|
|
@ -969,7 +969,7 @@ export function toDefinition<_embedded = _.GenericEmbedded>(v: _.Value<_embedded
|
|||
let _tmp0: ({}) | undefined;
|
||||
_tmp0 = _.is(v.label, $or) ? {} : void 0;
|
||||
if (_tmp0 !== void 0) {
|
||||
if (_.Array.isArray(v[0]) && v[0].length >= 2) {
|
||||
if (_.isSequence(v[0]) && v[0].length >= 2) {
|
||||
let _tmp1: (NamedAlternative<_embedded>) | undefined;
|
||||
_tmp1 = toNamedAlternative(v[0][0]);
|
||||
if (_tmp1 !== void 0) {
|
||||
|
@ -1006,7 +1006,7 @@ export function toDefinition<_embedded = _.GenericEmbedded>(v: _.Value<_embedded
|
|||
let _tmp7: ({}) | undefined;
|
||||
_tmp7 = _.is(v.label, $and) ? {} : void 0;
|
||||
if (_tmp7 !== void 0) {
|
||||
if (_.Array.isArray(v[0]) && v[0].length >= 2) {
|
||||
if (_.isSequence(v[0]) && v[0].length >= 2) {
|
||||
let _tmp8: (NamedPattern<_embedded>) | undefined;
|
||||
_tmp8 = toNamedPattern(v[0][0]);
|
||||
if (_tmp8 !== void 0) {
|
||||
|
@ -1317,7 +1317,7 @@ export function toCompoundPattern<_embedded = _.GenericEmbedded>(v: _.Value<_emb
|
|||
if (_tmp3 !== void 0) {
|
||||
let _tmp4: (Array<NamedPattern<_embedded>>) | undefined;
|
||||
_tmp4 = void 0;
|
||||
if (_.Array.isArray(v[0])) {
|
||||
if (_.isSequence(v[0])) {
|
||||
_tmp4 = [];
|
||||
for (const _tmp5 of v[0]) {
|
||||
let _tmp6: (NamedPattern<_embedded>) | undefined;
|
||||
|
@ -1343,7 +1343,7 @@ export function toCompoundPattern<_embedded = _.GenericEmbedded>(v: _.Value<_emb
|
|||
if (_tmp7 !== void 0) {
|
||||
let _tmp8: (Array<NamedPattern<_embedded>>) | undefined;
|
||||
_tmp8 = void 0;
|
||||
if (_.Array.isArray(v[0])) {
|
||||
if (_.isSequence(v[0])) {
|
||||
_tmp8 = [];
|
||||
for (const _tmp9 of v[0]) {
|
||||
let _tmp10: (NamedPattern<_embedded>) | undefined;
|
||||
|
@ -1543,7 +1543,7 @@ export function asNamedAlternative<_embedded = _.GenericEmbedded>(v: _.Value<_em
|
|||
|
||||
export function toNamedAlternative<_embedded = _.GenericEmbedded>(v: _.Value<_embedded>): undefined | (NamedAlternative<_embedded> & {__as_preserve__(): _.Value<_embedded>}) {
|
||||
let result: undefined | (NamedAlternative<_embedded> & {__as_preserve__(): _.Value<_embedded>});
|
||||
if (_.Array.isArray(v) && v.length === 2) {
|
||||
if (_.isSequence(v) && v.length === 2) {
|
||||
let _tmp0: (string) | undefined;
|
||||
_tmp0 = typeof v[0] === 'string' ? v[0] : void 0;
|
||||
if (_tmp0 !== void 0) {
|
||||
|
@ -1717,7 +1717,7 @@ export function toModulePath<_embedded = _.GenericEmbedded>(v: _.Value<_embedded
|
|||
let _tmp0: (Array<symbol>) | undefined;
|
||||
let result: undefined | ModulePath;
|
||||
_tmp0 = void 0;
|
||||
if (_.Array.isArray(v)) {
|
||||
if (_.isSequence(v)) {
|
||||
_tmp0 = [];
|
||||
for (const _tmp1 of v) {
|
||||
let _tmp2: (symbol) | undefined;
|
||||
|
|
Loading…
Reference in New Issue