Best JavaScript code snippet using ng-mocks
index.js
Source:index.js
1module.exports = {};2module.exports.F = /*#__PURE__*/require('./F');3module.exports.T = /*#__PURE__*/require('./T');4module.exports.__ = /*#__PURE__*/require('./__');5module.exports.add = /*#__PURE__*/require('./add');6module.exports.addIndex = /*#__PURE__*/require('./addIndex');7module.exports.adjust = /*#__PURE__*/require('./adjust');8module.exports.all = /*#__PURE__*/require('./all');9module.exports.allPass = /*#__PURE__*/require('./allPass');10module.exports.always = /*#__PURE__*/require('./always');11module.exports.and = /*#__PURE__*/require('./and');12module.exports.any = /*#__PURE__*/require('./any');13module.exports.anyPass = /*#__PURE__*/require('./anyPass');14module.exports.ap = /*#__PURE__*/require('./ap');15module.exports.aperture = /*#__PURE__*/require('./aperture');16module.exports.append = /*#__PURE__*/require('./append');17module.exports.apply = /*#__PURE__*/require('./apply');18module.exports.applySpec = /*#__PURE__*/require('./applySpec');19module.exports.applyTo = /*#__PURE__*/require('./applyTo');20module.exports.ascend = /*#__PURE__*/require('./ascend');21module.exports.assoc = /*#__PURE__*/require('./assoc');22module.exports.assocPath = /*#__PURE__*/require('./assocPath');23module.exports.binary = /*#__PURE__*/require('./binary');24module.exports.bind = /*#__PURE__*/require('./bind');25module.exports.both = /*#__PURE__*/require('./both');26module.exports.call = /*#__PURE__*/require('./call');27module.exports.chain = /*#__PURE__*/require('./chain');28module.exports.clamp = /*#__PURE__*/require('./clamp');29module.exports.clone = /*#__PURE__*/require('./clone');30module.exports.comparator = /*#__PURE__*/require('./comparator');31module.exports.complement = /*#__PURE__*/require('./complement');32module.exports.compose = /*#__PURE__*/require('./compose');33module.exports.composeK = /*#__PURE__*/require('./composeK');34module.exports.composeP = /*#__PURE__*/require('./composeP');35module.exports.composeWith = /*#__PURE__*/require('./composeWith');36module.exports.concat = /*#__PURE__*/require('./concat');37module.exports.cond = /*#__PURE__*/require('./cond');38module.exports.construct = /*#__PURE__*/require('./construct');39module.exports.constructN = /*#__PURE__*/require('./constructN');40module.exports.contains = /*#__PURE__*/require('./contains');41module.exports.converge = /*#__PURE__*/require('./converge');42module.exports.countBy = /*#__PURE__*/require('./countBy');43module.exports.curry = /*#__PURE__*/require('./curry');44module.exports.curryN = /*#__PURE__*/require('./curryN');45module.exports.dec = /*#__PURE__*/require('./dec');46module.exports.defaultTo = /*#__PURE__*/require('./defaultTo');47module.exports.descend = /*#__PURE__*/require('./descend');48module.exports.difference = /*#__PURE__*/require('./difference');49module.exports.differenceWith = /*#__PURE__*/require('./differenceWith');50module.exports.dissoc = /*#__PURE__*/require('./dissoc');51module.exports.dissocPath = /*#__PURE__*/require('./dissocPath');52module.exports.divide = /*#__PURE__*/require('./divide');53module.exports.drop = /*#__PURE__*/require('./drop');54module.exports.dropLast = /*#__PURE__*/require('./dropLast');55module.exports.dropLastWhile = /*#__PURE__*/require('./dropLastWhile');56module.exports.dropRepeats = /*#__PURE__*/require('./dropRepeats');57module.exports.dropRepeatsWith = /*#__PURE__*/require('./dropRepeatsWith');58module.exports.dropWhile = /*#__PURE__*/require('./dropWhile');59module.exports.either = /*#__PURE__*/require('./either');60module.exports.empty = /*#__PURE__*/require('./empty');61module.exports.endsWith = /*#__PURE__*/require('./endsWith');62module.exports.eqBy = /*#__PURE__*/require('./eqBy');63module.exports.eqProps = /*#__PURE__*/require('./eqProps');64module.exports.equals = /*#__PURE__*/require('./equals');65module.exports.evolve = /*#__PURE__*/require('./evolve');66module.exports.filter = /*#__PURE__*/require('./filter');67module.exports.find = /*#__PURE__*/require('./find');68module.exports.findIndex = /*#__PURE__*/require('./findIndex');69module.exports.findLast = /*#__PURE__*/require('./findLast');70module.exports.findLastIndex = /*#__PURE__*/require('./findLastIndex');71module.exports.flatten = /*#__PURE__*/require('./flatten');72module.exports.flip = /*#__PURE__*/require('./flip');73module.exports.forEach = /*#__PURE__*/require('./forEach');74module.exports.forEachObjIndexed = /*#__PURE__*/require('./forEachObjIndexed');75module.exports.fromPairs = /*#__PURE__*/require('./fromPairs');76module.exports.groupBy = /*#__PURE__*/require('./groupBy');77module.exports.groupWith = /*#__PURE__*/require('./groupWith');78module.exports.gt = /*#__PURE__*/require('./gt');79module.exports.gte = /*#__PURE__*/require('./gte');80module.exports.has = /*#__PURE__*/require('./has');81module.exports.hasIn = /*#__PURE__*/require('./hasIn');82module.exports.hasPath = /*#__PURE__*/require('./hasPath');83module.exports.head = /*#__PURE__*/require('./head');84module.exports.identical = /*#__PURE__*/require('./identical');85module.exports.identity = /*#__PURE__*/require('./identity');86module.exports.ifElse = /*#__PURE__*/require('./ifElse');87module.exports.inc = /*#__PURE__*/require('./inc');88module.exports.includes = /*#__PURE__*/require('./includes');89module.exports.indexBy = /*#__PURE__*/require('./indexBy');90module.exports.indexOf = /*#__PURE__*/require('./indexOf');91module.exports.init = /*#__PURE__*/require('./init');92module.exports.innerJoin = /*#__PURE__*/require('./innerJoin');93module.exports.insert = /*#__PURE__*/require('./insert');94module.exports.insertAll = /*#__PURE__*/require('./insertAll');95module.exports.intersection = /*#__PURE__*/require('./intersection');96module.exports.intersperse = /*#__PURE__*/require('./intersperse');97module.exports.into = /*#__PURE__*/require('./into');98module.exports.invert = /*#__PURE__*/require('./invert');99module.exports.invertObj = /*#__PURE__*/require('./invertObj');100module.exports.invoker = /*#__PURE__*/require('./invoker');101module.exports.is = /*#__PURE__*/require('./is');102module.exports.isEmpty = /*#__PURE__*/require('./isEmpty');103module.exports.isNil = /*#__PURE__*/require('./isNil');104module.exports.join = /*#__PURE__*/require('./join');105module.exports.juxt = /*#__PURE__*/require('./juxt');106module.exports.keys = /*#__PURE__*/require('./keys');107module.exports.keysIn = /*#__PURE__*/require('./keysIn');108module.exports.last = /*#__PURE__*/require('./last');109module.exports.lastIndexOf = /*#__PURE__*/require('./lastIndexOf');110module.exports.length = /*#__PURE__*/require('./length');111module.exports.lens = /*#__PURE__*/require('./lens');112module.exports.lensIndex = /*#__PURE__*/require('./lensIndex');113module.exports.lensPath = /*#__PURE__*/require('./lensPath');114module.exports.lensProp = /*#__PURE__*/require('./lensProp');115module.exports.lift = /*#__PURE__*/require('./lift');116module.exports.liftN = /*#__PURE__*/require('./liftN');117module.exports.lt = /*#__PURE__*/require('./lt');118module.exports.lte = /*#__PURE__*/require('./lte');119module.exports.map = /*#__PURE__*/require('./map');120module.exports.mapAccum = /*#__PURE__*/require('./mapAccum');121module.exports.mapAccumRight = /*#__PURE__*/require('./mapAccumRight');122module.exports.mapObjIndexed = /*#__PURE__*/require('./mapObjIndexed');123module.exports.match = /*#__PURE__*/require('./match');124module.exports.mathMod = /*#__PURE__*/require('./mathMod');125module.exports.max = /*#__PURE__*/require('./max');126module.exports.maxBy = /*#__PURE__*/require('./maxBy');127module.exports.mean = /*#__PURE__*/require('./mean');128module.exports.median = /*#__PURE__*/require('./median');129module.exports.memoizeWith = /*#__PURE__*/require('./memoizeWith');130module.exports.merge = /*#__PURE__*/require('./merge');131module.exports.mergeAll = /*#__PURE__*/require('./mergeAll');132module.exports.mergeDeepLeft = /*#__PURE__*/require('./mergeDeepLeft');133module.exports.mergeDeepRight = /*#__PURE__*/require('./mergeDeepRight');134module.exports.mergeDeepWith = /*#__PURE__*/require('./mergeDeepWith');135module.exports.mergeDeepWithKey = /*#__PURE__*/require('./mergeDeepWithKey');136module.exports.mergeLeft = /*#__PURE__*/require('./mergeLeft');137module.exports.mergeRight = /*#__PURE__*/require('./mergeRight');138module.exports.mergeWith = /*#__PURE__*/require('./mergeWith');139module.exports.mergeWithKey = /*#__PURE__*/require('./mergeWithKey');140module.exports.min = /*#__PURE__*/require('./min');141module.exports.minBy = /*#__PURE__*/require('./minBy');142module.exports.modulo = /*#__PURE__*/require('./modulo');143module.exports.move = /*#__PURE__*/require('./move');144module.exports.multiply = /*#__PURE__*/require('./multiply');145module.exports.nAry = /*#__PURE__*/require('./nAry');146module.exports.negate = /*#__PURE__*/require('./negate');147module.exports.none = /*#__PURE__*/require('./none');148module.exports.not = /*#__PURE__*/require('./not');149module.exports.nth = /*#__PURE__*/require('./nth');150module.exports.nthArg = /*#__PURE__*/require('./nthArg');151module.exports.o = /*#__PURE__*/require('./o');152module.exports.objOf = /*#__PURE__*/require('./objOf');153module.exports.of = /*#__PURE__*/require('./of');154module.exports.omit = /*#__PURE__*/require('./omit');155module.exports.once = /*#__PURE__*/require('./once');156module.exports.or = /*#__PURE__*/require('./or');157module.exports.otherwise = /*#__PURE__*/require('./otherwise');158module.exports.over = /*#__PURE__*/require('./over');159module.exports.pair = /*#__PURE__*/require('./pair');160module.exports.partial = /*#__PURE__*/require('./partial');161module.exports.partialRight = /*#__PURE__*/require('./partialRight');162module.exports.partition = /*#__PURE__*/require('./partition');163module.exports.path = /*#__PURE__*/require('./path');164module.exports.pathEq = /*#__PURE__*/require('./pathEq');165module.exports.pathOr = /*#__PURE__*/require('./pathOr');166module.exports.pathSatisfies = /*#__PURE__*/require('./pathSatisfies');167module.exports.pick = /*#__PURE__*/require('./pick');168module.exports.pickAll = /*#__PURE__*/require('./pickAll');169module.exports.pickBy = /*#__PURE__*/require('./pickBy');170module.exports.pipe = /*#__PURE__*/require('./pipe');171module.exports.pipeK = /*#__PURE__*/require('./pipeK');172module.exports.pipeP = /*#__PURE__*/require('./pipeP');173module.exports.pipeWith = /*#__PURE__*/require('./pipeWith');174module.exports.pluck = /*#__PURE__*/require('./pluck');175module.exports.prepend = /*#__PURE__*/require('./prepend');176module.exports.product = /*#__PURE__*/require('./product');177module.exports.project = /*#__PURE__*/require('./project');178module.exports.prop = /*#__PURE__*/require('./prop');179module.exports.propEq = /*#__PURE__*/require('./propEq');180module.exports.propIs = /*#__PURE__*/require('./propIs');181module.exports.propOr = /*#__PURE__*/require('./propOr');182module.exports.propSatisfies = /*#__PURE__*/require('./propSatisfies');183module.exports.props = /*#__PURE__*/require('./props');184module.exports.range = /*#__PURE__*/require('./range');185module.exports.reduce = /*#__PURE__*/require('./reduce');186module.exports.reduceBy = /*#__PURE__*/require('./reduceBy');187module.exports.reduceRight = /*#__PURE__*/require('./reduceRight');188module.exports.reduceWhile = /*#__PURE__*/require('./reduceWhile');189module.exports.reduced = /*#__PURE__*/require('./reduced');190module.exports.reject = /*#__PURE__*/require('./reject');191module.exports.remove = /*#__PURE__*/require('./remove');192module.exports.repeat = /*#__PURE__*/require('./repeat');193module.exports.replace = /*#__PURE__*/require('./replace');194module.exports.reverse = /*#__PURE__*/require('./reverse');195module.exports.scan = /*#__PURE__*/require('./scan');196module.exports.sequence = /*#__PURE__*/require('./sequence');197module.exports.set = /*#__PURE__*/require('./set');198module.exports.slice = /*#__PURE__*/require('./slice');199module.exports.sort = /*#__PURE__*/require('./sort');200module.exports.sortBy = /*#__PURE__*/require('./sortBy');201module.exports.sortWith = /*#__PURE__*/require('./sortWith');202module.exports.split = /*#__PURE__*/require('./split');203module.exports.splitAt = /*#__PURE__*/require('./splitAt');204module.exports.splitEvery = /*#__PURE__*/require('./splitEvery');205module.exports.splitWhen = /*#__PURE__*/require('./splitWhen');206module.exports.startsWith = /*#__PURE__*/require('./startsWith');207module.exports.subtract = /*#__PURE__*/require('./subtract');208module.exports.sum = /*#__PURE__*/require('./sum');209module.exports.symmetricDifference = /*#__PURE__*/require('./symmetricDifference');210module.exports.symmetricDifferenceWith = /*#__PURE__*/require('./symmetricDifferenceWith');211module.exports.tail = /*#__PURE__*/require('./tail');212module.exports.take = /*#__PURE__*/require('./take');213module.exports.takeLast = /*#__PURE__*/require('./takeLast');214module.exports.takeLastWhile = /*#__PURE__*/require('./takeLastWhile');215module.exports.takeWhile = /*#__PURE__*/require('./takeWhile');216module.exports.tap = /*#__PURE__*/require('./tap');217module.exports.test = /*#__PURE__*/require('./test');218module.exports.then = /*#__PURE__*/require('./then');219module.exports.times = /*#__PURE__*/require('./times');220module.exports.toLower = /*#__PURE__*/require('./toLower');221module.exports.toPairs = /*#__PURE__*/require('./toPairs');222module.exports.toPairsIn = /*#__PURE__*/require('./toPairsIn');223module.exports.toString = /*#__PURE__*/require('./toString');224module.exports.toUpper = /*#__PURE__*/require('./toUpper');225module.exports.transduce = /*#__PURE__*/require('./transduce');226module.exports.transpose = /*#__PURE__*/require('./transpose');227module.exports.traverse = /*#__PURE__*/require('./traverse');228module.exports.trim = /*#__PURE__*/require('./trim');229module.exports.tryCatch = /*#__PURE__*/require('./tryCatch');230module.exports.type = /*#__PURE__*/require('./type');231module.exports.unapply = /*#__PURE__*/require('./unapply');232module.exports.unary = /*#__PURE__*/require('./unary');233module.exports.uncurryN = /*#__PURE__*/require('./uncurryN');234module.exports.unfold = /*#__PURE__*/require('./unfold');235module.exports.union = /*#__PURE__*/require('./union');236module.exports.unionWith = /*#__PURE__*/require('./unionWith');237module.exports.uniq = /*#__PURE__*/require('./uniq');238module.exports.uniqBy = /*#__PURE__*/require('./uniqBy');239module.exports.uniqWith = /*#__PURE__*/require('./uniqWith');240module.exports.unless = /*#__PURE__*/require('./unless');241module.exports.unnest = /*#__PURE__*/require('./unnest');242module.exports.until = /*#__PURE__*/require('./until');243module.exports.update = /*#__PURE__*/require('./update');244module.exports.useWith = /*#__PURE__*/require('./useWith');245module.exports.values = /*#__PURE__*/require('./values');246module.exports.valuesIn = /*#__PURE__*/require('./valuesIn');247module.exports.view = /*#__PURE__*/require('./view');248module.exports.when = /*#__PURE__*/require('./when');249module.exports.where = /*#__PURE__*/require('./where');250module.exports.whereEq = /*#__PURE__*/require('./whereEq');251module.exports.without = /*#__PURE__*/require('./without');252module.exports.xprod = /*#__PURE__*/require('./xprod');253module.exports.zip = /*#__PURE__*/require('./zip');254module.exports.zipObj = /*#__PURE__*/require('./zipObj');255module.exports.zipWith = /*#__PURE__*/require('./zipWith');...
built-in-definitions.js
Source:built-in-definitions.js
1"use strict";2exports.__esModule = true;3exports.StaticProperties = exports.InstanceProperties = exports.BuiltIns = exports.CommonIterators = void 0;4var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));5function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }6const define = (name, pure, global = [], meta) => {7 return {8 name,9 pure,10 global,11 meta12 };13};14const pureAndGlobal = (pure, global, minRuntimeVersion = null) => define(global[0], pure, global, {15 minRuntimeVersion16});17const globalOnly = global => define(global[0], null, global);18const pureOnly = (pure, name) => define(name, pure, []);19const ArrayNatureIterators = ["es6.object.to-string", "es6.array.iterator", "web.dom.iterable"];20const CommonIterators = ["es6.string.iterator", ...ArrayNatureIterators];21exports.CommonIterators = CommonIterators;22const PromiseDependencies = ["es6.object.to-string", "es6.promise"];23const BuiltIns = {24 DataView: globalOnly(["es6.typed.data-view"]),25 Float32Array: globalOnly(["es6.typed.float32-array"]),26 Float64Array: globalOnly(["es6.typed.float64-array"]),27 Int8Array: globalOnly(["es6.typed.int8-array"]),28 Int16Array: globalOnly(["es6.typed.int16-array"]),29 Int32Array: globalOnly(["es6.typed.int32-array"]),30 Map: pureAndGlobal("map", ["es6.map", ...CommonIterators]),31 Number: globalOnly(["es6.number.constructor"]),32 Promise: pureAndGlobal("promise", PromiseDependencies),33 RegExp: globalOnly(["es6.regexp.constructor"]),34 Set: pureAndGlobal("set", ["es6.set", ...CommonIterators]),35 Symbol: pureAndGlobal("symbol", ["es6.symbol"]),36 Uint8Array: globalOnly(["es6.typed.uint8-array"]),37 Uint8ClampedArray: globalOnly(["es6.typed.uint8-clamped-array"]),38 Uint16Array: globalOnly(["es6.typed.uint16-array"]),39 Uint32Array: globalOnly(["es6.typed.uint32-array"]),40 WeakMap: pureAndGlobal("weak-map", ["es6.weak-map", ...CommonIterators]),41 WeakSet: pureAndGlobal("weak-set", ["es6.weak-set", ...CommonIterators]),42 setImmediate: pureOnly("set-immediate", "web.immediate"),43 clearImmediate: pureOnly("clear-immediate", "web.immediate"),44 parseFloat: pureOnly("parse-float", "es6.parse-float"),45 parseInt: pureOnly("parse-int", "es6.parse-int")46};47exports.BuiltIns = BuiltIns;48const InstanceProperties = {49 __defineGetter__: globalOnly(["es7.object.define-getter"]),50 __defineSetter__: globalOnly(["es7.object.define-setter"]),51 __lookupGetter__: globalOnly(["es7.object.lookup-getter"]),52 __lookupSetter__: globalOnly(["es7.object.lookup-setter"]),53 anchor: globalOnly(["es6.string.anchor"]),54 big: globalOnly(["es6.string.big"]),55 bind: globalOnly(["es6.function.bind"]),56 blink: globalOnly(["es6.string.blink"]),57 bold: globalOnly(["es6.string.bold"]),58 codePointAt: globalOnly(["es6.string.code-point-at"]),59 copyWithin: globalOnly(["es6.array.copy-within"]),60 endsWith: globalOnly(["es6.string.ends-with"]),61 entries: globalOnly(ArrayNatureIterators),62 every: globalOnly(["es6.array.every"]),63 fill: globalOnly(["es6.array.fill"]),64 filter: globalOnly(["es6.array.filter"]),65 finally: globalOnly(["es7.promise.finally", ...PromiseDependencies]),66 find: globalOnly(["es6.array.find"]),67 findIndex: globalOnly(["es6.array.find-index"]),68 fixed: globalOnly(["es6.string.fixed"]),69 flags: globalOnly(["es6.regexp.flags"]),70 flatMap: globalOnly(["es7.array.flat-map"]),71 fontcolor: globalOnly(["es6.string.fontcolor"]),72 fontsize: globalOnly(["es6.string.fontsize"]),73 forEach: globalOnly(["es6.array.for-each"]),74 includes: globalOnly(["es6.string.includes", "es7.array.includes"]),75 indexOf: globalOnly(["es6.array.index-of"]),76 italics: globalOnly(["es6.string.italics"]),77 keys: globalOnly(ArrayNatureIterators),78 lastIndexOf: globalOnly(["es6.array.last-index-of"]),79 link: globalOnly(["es6.string.link"]),80 map: globalOnly(["es6.array.map"]),81 match: globalOnly(["es6.regexp.match"]),82 name: globalOnly(["es6.function.name"]),83 padStart: globalOnly(["es7.string.pad-start"]),84 padEnd: globalOnly(["es7.string.pad-end"]),85 reduce: globalOnly(["es6.array.reduce"]),86 reduceRight: globalOnly(["es6.array.reduce-right"]),87 repeat: globalOnly(["es6.string.repeat"]),88 replace: globalOnly(["es6.regexp.replace"]),89 search: globalOnly(["es6.regexp.search"]),90 small: globalOnly(["es6.string.small"]),91 some: globalOnly(["es6.array.some"]),92 sort: globalOnly(["es6.array.sort"]),93 split: globalOnly(["es6.regexp.split"]),94 startsWith: globalOnly(["es6.string.starts-with"]),95 strike: globalOnly(["es6.string.strike"]),96 sub: globalOnly(["es6.string.sub"]),97 sup: globalOnly(["es6.string.sup"]),98 toISOString: globalOnly(["es6.date.to-iso-string"]),99 toJSON: globalOnly(["es6.date.to-json"]),100 toString: globalOnly(["es6.object.to-string", "es6.date.to-string", "es6.regexp.to-string"]),101 trim: globalOnly(["es6.string.trim"]),102 trimEnd: globalOnly(["es7.string.trim-right"]),103 trimLeft: globalOnly(["es7.string.trim-left"]),104 trimRight: globalOnly(["es7.string.trim-right"]),105 trimStart: globalOnly(["es7.string.trim-left"]),106 values: globalOnly(ArrayNatureIterators)107}; // This isn't present in older @babel/compat-data versions108exports.InstanceProperties = InstanceProperties;109if ("es6.array.slice" in _corejs2BuiltIns.default) {110 InstanceProperties.slice = globalOnly(["es6.array.slice"]);111}112const StaticProperties = {113 Array: {114 from: pureAndGlobal("array/from", ["es6.symbol", "es6.array.from", ...CommonIterators]),115 isArray: pureAndGlobal("array/is-array", ["es6.array.is-array"]),116 of: pureAndGlobal("array/of", ["es6.array.of"])117 },118 Date: {119 now: pureAndGlobal("date/now", ["es6.date.now"])120 },121 JSON: {122 stringify: pureOnly("json/stringify", "es6.symbol")123 },124 Math: {125 // 'Math' was not included in the 7.0.0126 // release of '@babel/runtime'. See issue https://github.com/babel/babel/pull/8616.127 acosh: pureAndGlobal("math/acosh", ["es6.math.acosh"], "7.0.1"),128 asinh: pureAndGlobal("math/asinh", ["es6.math.asinh"], "7.0.1"),129 atanh: pureAndGlobal("math/atanh", ["es6.math.atanh"], "7.0.1"),130 cbrt: pureAndGlobal("math/cbrt", ["es6.math.cbrt"], "7.0.1"),131 clz32: pureAndGlobal("math/clz32", ["es6.math.clz32"], "7.0.1"),132 cosh: pureAndGlobal("math/cosh", ["es6.math.cosh"], "7.0.1"),133 expm1: pureAndGlobal("math/expm1", ["es6.math.expm1"], "7.0.1"),134 fround: pureAndGlobal("math/fround", ["es6.math.fround"], "7.0.1"),135 hypot: pureAndGlobal("math/hypot", ["es6.math.hypot"], "7.0.1"),136 imul: pureAndGlobal("math/imul", ["es6.math.imul"], "7.0.1"),137 log1p: pureAndGlobal("math/log1p", ["es6.math.log1p"], "7.0.1"),138 log10: pureAndGlobal("math/log10", ["es6.math.log10"], "7.0.1"),139 log2: pureAndGlobal("math/log2", ["es6.math.log2"], "7.0.1"),140 sign: pureAndGlobal("math/sign", ["es6.math.sign"], "7.0.1"),141 sinh: pureAndGlobal("math/sinh", ["es6.math.sinh"], "7.0.1"),142 tanh: pureAndGlobal("math/tanh", ["es6.math.tanh"], "7.0.1"),143 trunc: pureAndGlobal("math/trunc", ["es6.math.trunc"], "7.0.1")144 },145 Number: {146 EPSILON: pureAndGlobal("number/epsilon", ["es6.number.epsilon"]),147 MIN_SAFE_INTEGER: pureAndGlobal("number/min-safe-integer", ["es6.number.min-safe-integer"]),148 MAX_SAFE_INTEGER: pureAndGlobal("number/max-safe-integer", ["es6.number.max-safe-integer"]),149 isFinite: pureAndGlobal("number/is-finite", ["es6.number.is-finite"]),150 isInteger: pureAndGlobal("number/is-integer", ["es6.number.is-integer"]),151 isSafeInteger: pureAndGlobal("number/is-safe-integer", ["es6.number.is-safe-integer"]),152 isNaN: pureAndGlobal("number/is-nan", ["es6.number.is-nan"]),153 parseFloat: pureAndGlobal("number/parse-float", ["es6.number.parse-float"]),154 parseInt: pureAndGlobal("number/parse-int", ["es6.number.parse-int"])155 },156 Object: {157 assign: pureAndGlobal("object/assign", ["es6.object.assign"]),158 create: pureAndGlobal("object/create", ["es6.object.create"]),159 defineProperties: pureAndGlobal("object/define-properties", ["es6.object.define-properties"]),160 defineProperty: pureAndGlobal("object/define-property", ["es6.object.define-property"]),161 entries: pureAndGlobal("object/entries", ["es7.object.entries"]),162 freeze: pureAndGlobal("object/freeze", ["es6.object.freeze"]),163 getOwnPropertyDescriptor: pureAndGlobal("object/get-own-property-descriptor", ["es6.object.get-own-property-descriptor"]),164 getOwnPropertyDescriptors: pureAndGlobal("object/get-own-property-descriptors", ["es7.object.get-own-property-descriptors"]),165 getOwnPropertyNames: pureAndGlobal("object/get-own-property-names", ["es6.object.get-own-property-names"]),166 getOwnPropertySymbols: pureAndGlobal("object/get-own-property-symbols", ["es6.symbol"]),167 getPrototypeOf: pureAndGlobal("object/get-prototype-of", ["es6.object.get-prototype-of"]),168 is: pureAndGlobal("object/is", ["es6.object.is"]),169 isExtensible: pureAndGlobal("object/is-extensible", ["es6.object.is-extensible"]),170 isFrozen: pureAndGlobal("object/is-frozen", ["es6.object.is-frozen"]),171 isSealed: pureAndGlobal("object/is-sealed", ["es6.object.is-sealed"]),172 keys: pureAndGlobal("object/keys", ["es6.object.keys"]),173 preventExtensions: pureAndGlobal("object/prevent-extensions", ["es6.object.prevent-extensions"]),174 seal: pureAndGlobal("object/seal", ["es6.object.seal"]),175 setPrototypeOf: pureAndGlobal("object/set-prototype-of", ["es6.object.set-prototype-of"]),176 values: pureAndGlobal("object/values", ["es7.object.values"])177 },178 Promise: {179 all: globalOnly(CommonIterators),180 race: globalOnly(CommonIterators)181 },182 Reflect: {183 apply: pureAndGlobal("reflect/apply", ["es6.reflect.apply"]),184 construct: pureAndGlobal("reflect/construct", ["es6.reflect.construct"]),185 defineProperty: pureAndGlobal("reflect/define-property", ["es6.reflect.define-property"]),186 deleteProperty: pureAndGlobal("reflect/delete-property", ["es6.reflect.delete-property"]),187 get: pureAndGlobal("reflect/get", ["es6.reflect.get"]),188 getOwnPropertyDescriptor: pureAndGlobal("reflect/get-own-property-descriptor", ["es6.reflect.get-own-property-descriptor"]),189 getPrototypeOf: pureAndGlobal("reflect/get-prototype-of", ["es6.reflect.get-prototype-of"]),190 has: pureAndGlobal("reflect/has", ["es6.reflect.has"]),191 isExtensible: pureAndGlobal("reflect/is-extensible", ["es6.reflect.is-extensible"]),192 ownKeys: pureAndGlobal("reflect/own-keys", ["es6.reflect.own-keys"]),193 preventExtensions: pureAndGlobal("reflect/prevent-extensions", ["es6.reflect.prevent-extensions"]),194 set: pureAndGlobal("reflect/set", ["es6.reflect.set"]),195 setPrototypeOf: pureAndGlobal("reflect/set-prototype-of", ["es6.reflect.set-prototype-of"])196 },197 String: {198 at: pureOnly("string/at", "es7.string.at"),199 fromCodePoint: pureAndGlobal("string/from-code-point", ["es6.string.from-code-point"]),200 raw: pureAndGlobal("string/raw", ["es6.string.raw"])201 },202 Symbol: {203 // FIXME: Pure disabled to work around zloirock/core-js#262.204 asyncIterator: globalOnly(["es6.symbol", "es7.symbol.async-iterator"]),205 for: pureOnly("symbol/for", "es6.symbol"),206 hasInstance: pureOnly("symbol/has-instance", "es6.symbol"),207 isConcatSpreadable: pureOnly("symbol/is-concat-spreadable", "es6.symbol"),208 iterator: define("es6.symbol", "symbol/iterator", CommonIterators),209 keyFor: pureOnly("symbol/key-for", "es6.symbol"),210 match: pureAndGlobal("symbol/match", ["es6.regexp.match"]),211 replace: pureOnly("symbol/replace", "es6.symbol"),212 search: pureOnly("symbol/search", "es6.symbol"),213 species: pureOnly("symbol/species", "es6.symbol"),214 split: pureOnly("symbol/split", "es6.symbol"),215 toPrimitive: pureOnly("symbol/to-primitive", "es6.symbol"),216 toStringTag: pureOnly("symbol/to-string-tag", "es6.symbol"),217 unscopables: pureOnly("symbol/unscopables", "es6.symbol")218 }219};...
create_state_container.ts
Source:create_state_container.ts
1/*2 * Licensed to Elasticsearch B.V. under one or more contributor3 * license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright5 * ownership. Elasticsearch B.V. licenses this file to you under6 * the Apache License, Version 2.0 (the "License"); you may7 * not use this file except in compliance with the License.8 * You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19import { BehaviorSubject } from 'rxjs';20import { skip } from 'rxjs/operators';21import deepFreeze from 'deep-freeze-strict';22import {23 PureTransitionsToTransitions,24 PureTransition,25 ReduxLikeStateContainer,26 PureSelectorsToSelectors,27 BaseState,28} from './types';29const $$observable = (typeof Symbol === 'function' && (Symbol as any).observable) || '@@observable';30const $$setActionType = '@@SET';31const isProduction =32 typeof window === 'object'33 ? process.env.NODE_ENV === 'production'34 : !process.env.NODE_ENV || process.env.NODE_ENV === 'production';35const defaultFreeze: <T>(value: T) => T = isProduction36 ? <T>(value: T) => value as T37 : <T>(value: T): T => {38 const isFreezable = value !== null && typeof value === 'object';39 if (isFreezable) return deepFreeze(value) as T;40 return value as T;41 };42export interface CreateStateContainerOptions {43 /**44 * Function to use when freezing state. Supply identity function45 *46 * ```ts47 * {48 * freeze: state => state,49 * }50 * ```51 *52 * if you expect that your state will be mutated externally an you cannot53 * prevent that.54 */55 freeze?: <T>(state: T) => T;56}57export function createStateContainer<State extends BaseState>(58 defaultState: State59): ReduxLikeStateContainer<State>;60export function createStateContainer<State extends BaseState, PureTransitions extends object>(61 defaultState: State,62 pureTransitions: PureTransitions63): ReduxLikeStateContainer<State, PureTransitions>;64export function createStateContainer<65 State extends BaseState,66 PureTransitions extends object,67 PureSelectors extends object68>(69 defaultState: State,70 pureTransitions: PureTransitions,71 pureSelectors: PureSelectors,72 options?: CreateStateContainerOptions73): ReduxLikeStateContainer<State, PureTransitions, PureSelectors>;74export function createStateContainer<75 State extends BaseState,76 PureTransitions extends object,77 PureSelectors extends object78>(79 defaultState: State,80 pureTransitions: PureTransitions = {} as PureTransitions,81 pureSelectors: PureSelectors = {} as PureSelectors,82 options: CreateStateContainerOptions = {}83): ReduxLikeStateContainer<State, PureTransitions, PureSelectors> {84 const { freeze = defaultFreeze } = options;85 const data$ = new BehaviorSubject<State>(freeze(defaultState));86 const state$ = data$.pipe(skip(1));87 const get = () => data$.getValue();88 const container: ReduxLikeStateContainer<State, PureTransitions, PureSelectors> = {89 get,90 state$,91 getState: () => data$.getValue(),92 set: (state: State) => {93 container.dispatch({ type: $$setActionType, args: [state] });94 },95 reducer: (state, action) => {96 if (action.type === $$setActionType) {97 return freeze(action.args[0] as State);98 }99 const pureTransition = (pureTransitions as Record<string, PureTransition<State, any[]>>)[100 action.type101 ];102 return pureTransition ? freeze(pureTransition(state)(...action.args)) : state;103 },104 replaceReducer: (nextReducer) => (container.reducer = nextReducer),105 dispatch: (action) => data$.next(container.reducer(get(), action)),106 transitions: Object.keys(pureTransitions).reduce<PureTransitionsToTransitions<PureTransitions>>(107 (acc, type) => ({ ...acc, [type]: (...args: any) => container.dispatch({ type, args }) }),108 {} as PureTransitionsToTransitions<PureTransitions>109 ),110 selectors: Object.keys(pureSelectors).reduce<PureSelectorsToSelectors<PureSelectors>>(111 (acc, selector) => ({112 ...acc,113 [selector]: (...args: any) => (pureSelectors as any)[selector](get())(...args),114 }),115 {} as PureSelectorsToSelectors<PureSelectors>116 ),117 addMiddleware: (middleware) =>118 (container.dispatch = middleware(container as any)(container.dispatch)),119 subscribe: (listener: (state: State) => void) => {120 const subscription = state$.subscribe(listener);121 return () => subscription.unsubscribe();122 },123 [$$observable]: state$,124 };125 return container;...
Using AI Code Generation
1import { ComponentFixture, TestBed } from '@angular/core/testing';2import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';3import { AppComponent } from './app.component';4describe('AppComponent', () => {5 let component: AppComponent;6 let fixture: ComponentFixture<AppComponent>;7 beforeEach(() => {8 MockBuilder(AppComponent);9 fixture = MockRender(AppComponent);10 component = fixture.componentInstance;11 });12 it('should create', () => {13 expect(component).toBeTruthy();14 });15 it('should have a title', () => {16 expect(component.title).toEqual('test');17 });18 it('should render title', () => {19 const compiled = fixture.nativeElement as HTMLElement;20 expect(compiled.querySelector('h1')?.textContent).toContain(21 );22 });23 it('should render title by ngMocks', () => {24 const compiled = ngMocks.find('h1');25 expect(compiled).toHaveText('Welcome to test!');26 });27});28import { ComponentFixture, TestBed } from '@angular/core/testing';29import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';30import { AppComponent } from './app.component';31describe('AppComponent', () => {32 let component: AppComponent;33 let fixture: ComponentFixture<AppComponent>;34 beforeEach(async () => {35 await TestBed.configureTestingModule({36 }).compileComponents();37 });38 beforeEach(() => {39 fixture = TestBed.createComponent(AppComponent);40 component = fixture.componentInstance;41 fixture.detectChanges();42 });43 it('should create', () => {44 expect(component).toBeTruthy();45 });46 it('should have a title', () => {47 expect(component.title).toEqual('test');48 });49 it('should render title', () => {50 const compiled = fixture.nativeElement as HTMLElement;51 expect(compiled.querySelector('h1')?.textContent).toContain(52 );53 });54 it('should render title by ngMocks', () => {55 const compiled = ngMocks.find('h1');56 expect(compiled).toHaveText('Welcome to test!');57 });58});
Using AI Code Generation
1import { MockBuilder, MockRender } from 'ng-mocks';2import { AppModule } from './app.module';3import { AppComponent } from './app.component';4import { TestBed } from '@angular/core/testing';5describe('AppComponent', () => {6 beforeEach(() => MockBuilder(AppComponent, AppModule));7 it('should render the component', () => {8 const fixture = MockRender(AppComponent);9 expect(fixture.point.componentInstance).toBeDefined();10 });11});12import { NgModule } from '@angular/core';13import { BrowserModule } from '@angular/platform-browser';14import { AppComponent } from './app.component';15@NgModule({16 imports: [BrowserModule],17})18export class AppModule {}19import { Component } from '@angular/core';20@Component({21})22export class AppComponent {}23import { TestBed } from '@angular/core/testing';24import { AppComponent } from './app.component';25describe('AppComponent', () => {26 beforeEach(async () => {27 await TestBed.configureTestingModule({28 }).compileComponents();29 });30 it('should create the app', () => {31 const fixture = TestBed.createComponent(AppComponent);32 const app = fixture.componentInstance;33 expect(app).toBeTruthy();34 });35 it(`should have as title 'ng-mocks'`, () => {36 const fixture = TestBed.createComponent(AppComponent);37 const app = fixture.componentInstance;38 expect(app.title).toEqual('ng-mocks');39 });40 it('should render title', () => {41 const fixture = TestBed.createComponent(AppComponent);42 fixture.detectChanges();43 const compiled = fixture.nativeElement;44 expect(compiled.querySelector('h1').textContent).toContain(45 );46 });47});48import { MockBuilder, MockRender } from 'ng-mocks';49import { AppComponent } from './app.component';50import { AppModule } from './app.module';51describe('AppComponent', () => {52 beforeEach(() => MockBuilder(AppComponent, AppModule));53 it('should create the app', () => {54 const fixture = MockRender(AppComponent);55 expect(fixture.point.componentInstance).toBeDefined();56 });57 it(`should have as title 'ng-mocks'`, () => {58 const fixture = MockRender(AppComponent);
Using AI Code Generation
1import { TestBed } from '@angular/core/testing';2import { AppComponent } from './app.component';3import { MockBuilder } from 'ng-mocks';4describe('AppComponent', () => {5 beforeEach(() => MockBuilder(AppComponent));6 it('should create the app', () => {7 const fixture = TestBed.createComponent(AppComponent);8 const app = fixture.debugElement.componentInstance;9 expect(app).toBeTruthy();10 });11});12import { TestBed, async } from '@angular/core/testing';13import { AppComponent } from './app.component';14describe('AppComponent', () => {15 beforeEach(async(() => {16 TestBed.configureTestingModule({17 }).compileComponents();18 }));19 it('should create the app', () => {20 const fixture = TestBed.createComponent(AppComponent);21 const app = fixture.debugElement.componentInstance;22 expect(app).toBeTruthy();23 });24});
Using AI Code Generation
1import { MockBuilder, MockRender } from 'ng-mocks';2import { AppModule } from '../app/app.module';3describe('AppComponent', () => {4 beforeEach(() => MockBuilder(AppComponent, AppModule));5 it('should create the app', () => {6 const fixture = MockRender(AppComponent);7 const app = fixture.debugElement.componentInstance;8 expect(app).toBeTruthy();9 });10 it(`should have as title 'app'`, () => {11 const fixture = MockRender(AppComponent);12 const app = fixture.debugElement.componentInstance;13 expect(app.title).toEqual('app');14 });15 it('should render title in a h1 tag', () => {16 const fixture = MockRender(AppComponent);17 fixture.detectChanges();18 const compiled = fixture.debugElement.nativeElement;19 expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');20 });21});22import { NgModule } from '@angular/core';23import { BrowserModule } from '@angular/platform-browser';24import { AppComponent } from './app.component';25@NgModule({26 imports: [27})28export class AppModule { }29import { Component } from '@angular/core';30@Component({31})32export class AppComponent {33 title = 'app';34}35 Welcome to {{title}}!36/* You can add global styles to this file, and also import other style files */37body {38 margin: 0;39 font-family: Roboto, "Helvetica Neue", sans-serif;40}41{42 "compilerOptions": {43 },
Using AI Code Generation
1import { TestBed } from '@angular/core/testing';2import { MyComponent } from './my.component';3import { MyService } from './my.service';4import { MockModule } from 'ng-mocks';5describe('MyComponent', () => {6 let component: MyComponent;7 let service: MyService;8 beforeEach(() => {9 TestBed.configureTestingModule({10 imports: [11 MockModule(MyService),12 });13 component = TestBed.get(MyComponent);14 service = TestBed.get(MyService);15 });16 it('should create', () => {17 expect(component).toBeTruthy();18 });19 it('should use mocked service', () => {20 expect(service).toBeTruthy();21 expect(service.value).toBe('mocked');22 });23});24import { Component } from '@angular/core';25import { MyService } from './my.service';26@Component({27 template: `{{ service.value }}`,28})29export class MyComponent {30 constructor(31 ) {32 }33}34import { Injectable } from '@angular/core';35@Injectable()36export class MyService {37 public value = 'real';38}39import { TestBed } from '@angular/core/testing';40import { MyService } from './my.service';41describe('MyService', () => {42 let service: MyService;43 beforeEach(() => {44 TestBed.configureTestingModule({45 });46 service = TestBed.get(MyService);47 });48 it('should create', () => {49 expect(service).toBeTruthy();50 });51 it('should have real value', () => {52 expect(service).toBeTruthy();53 expect(service.value).toBe('real');54 });55});56import { Injectable } from '@angular/core';57@Injectable()58export class MyServiceMock {59 public value = 'mocked';60}61{62 "compilerOptions": {63 },
Using AI Code Generation
1import { TestBed } from '@angular/core/testing';2import { MockBuilder, MockRender } from 'ng-mocks';3describe('MyComponent', () => {4 beforeEach(() => MockBuilder(MyComponent, MyModule));5 it('renders the component', () => {6 const fixture = MockRender(MyComponent);7 expect(fixture.point.componentInstance).toBeDefined();8 });9});10import { TestBed } from '@angular/core/testing';11import { MockBuilder, MockRender } from 'ng-mocks';12describe('MyComponent', () => {13 beforeEach(() => MockBuilder(MyComponent, MyModule));14 it('renders the component', () => {15 const fixture = MockRender(MyComponent);16 expect(fixture.point.componentInstance).toBeDefined();17 });18});19import { TestBed } from '@angular/core/testing';20import { MockBuilder, MockRender } from 'ng-mocks';21describe('MyComponent', () => {22 beforeEach(() => MockBuilder(MyComponent, MyModule));23 it('renders the component', () => {24 const fixture = MockRender(MyComponent);25 expect(fixture.point.componentInstance).toBeDefined();26 });27});28import { TestBed } from '@angular/core/testing';29import { MockBuilder, MockRender } from 'ng-mocks';30describe('MyComponent', () => {31 beforeEach(() => MockBuilder(MyComponent, MyModule));32 it('renders the component', () => {33 const fixture = MockRender(MyComponent);34 expect(fixture.point.componentInstance).toBeDefined();35 });36});37import { TestBed } from '@angular/core/testing';38import { MockBuilder, MockRender } from 'ng-mocks';39describe('MyComponent', () => {40 beforeEach(() => MockBuilder(MyComponent, MyModule));41 it('renders the component', () => {42 const fixture = MockRender(MyComponent);43 expect(fixture.point.componentInstance).toBeDefined();44 });45});46import { TestBed } from '@angular/core/testing';47import { MockBuilder, MockRender } from 'ng-mocks';48describe('MyComponent', () => {49 beforeEach(() => MockBuilder(MyComponent,
Using AI Code Generation
1import { MockBuilder } from 'ng-mocks';2import { MyComponent } from './my.component';3import { MyModule } from './my.module';4describe('MyComponent', () => {5 beforeEach(() => MockBuilder(MyComponent, MyModule));6 it('should create', () => {7 const fixture = MockRender(MyComponent);8 expect(fixture.point.componentInstance).toBeDefined();9 });10});11import { Component } from '@angular/core';12@Component({13})14export class MyComponent {}15import { NgModule } from '@angular/core';16import { CommonModule } from '@angular/common';17import { MyComponent } from './my.component';18@NgModule({19 imports: [CommonModule],20})21export class MyModule {}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!