#node12
Explore tagged Tumblr posts
Text
Using ES6 Modules in Node.js
To get this working install Node.js 12:
nvm install 12
Then ensure your files end in .mjs to specify them as modules. Then either run Node.js with --experimental-modules or install the 'esm' package and use -r esm instead. This installation also gets rid of the warning messages that --experimental-modules gives. Here is an example:
backendImports.mjs
import moduleA from './testModule'; moduleA.helloWorld(); // Hello world console.log(moduleA.property1); // value1
testModule.mjs
export const helloWorld = () => { console.log('Hello world'); }; export const property1 = 'value1'; export default { helloWorld, property1 };
Which is run with node -r esm 2019/backendImports.mjs if you installed 'esm'. So far that does exactly what require does, but now at least it matches more modern import syntax used by bundlers like Webpack (which is used by React and modern Angular). Though the real advantage is the flexibility it gives. For example, specific parts of the module can be extracted instead in one line of code:
import { helloWorld } from './testModule'; helloWorld(); // Hello world
All parts of the module can be automatically imported too with * and assigned to a namespace in case no default export was given:
import * as moduleA2 from './testModule'; moduleA2.helloWorld(); // Hello world console.info(moduleA2.property1); // value1
Github Location https://github.com/Jacob-Friesen/obscurejs/blob/master/2019/backendImports.mjs
8 notes
·
View notes
Link
This utility tool is known as node-report that was recently brought into the Node.js core. It helps to detect abnormal terminations, memory leaks, high CPU usage, unexpected errors and more in Nodejs development.
#nodejs#node12#node js development services#node#hire nodejs developers#hire dot net developers#features of node12
0 notes
Link
Node JS continues through its yearly release cycle with Version 12, which is code-named as erbium. Since the version is even-numbered, it’ll enter as long-term Support (LTS). It begins in Oct 2019 and spans until April 2022.
Node 12 comes with notable options and runtime upgrades. Node uses the V8 engine from Google, found in Chrome, and can incorporate the updates from that too.
0 notes
Text
CIのcacheに使うkeyをどう管理するか
CIのcacheに使うkeyをどう管理するか
- uses: actions/cache@v2 with: path: node_modules key: ${{ 'ここをどうするか' }}
node_modulesをcacheする場合、基本的には以下のような情報をkeyとして使用する。
${{ runner.os }} node_modulesはOS依存の内容が含まれるため、OSが変わると使用できない
node_version(node12とかnode14とか) node_modulesはnodeのバージョン依存の内容が含まれるため、nodeのバージョンが変わると使用できない
${{ hashFiles('yarn.lock') }} lockファイルのhash
しかし、これだけだと以下のような理由でcacheをクリアしたくなったときに困る。
nodeのバージョンは変わらないが、yarnのバージョンは変えたい keyにyarnのバージョンを含めてもいいかもしれない
cacheの状態が���安定で内容が壊れている
気分
そのため、keyには以下のような方法でcacheバージョン的なものが付与されることが多い。
直接記述
直接keyの中にcache1と書いて数字を増やす
Pros
設定ファイルを見れば現在のバージョン状態がわかる
更新方法がわかりやすい
特定のブランチのみacheをクリアすることが容易
Cons
更新が手間(文字列置換で行うとそこまででもないけど)
全体での一律管理ができない
環境変数
CIサービスの環境変数経由で埋め込む
Pros
更新は簡単
全体での一律管理がでできる
Cons
CIサービス(github actions)によっては環境変数の設定に権限が必要
リポジトリ内のファイルのみで現在のバージョン状態がわからない
更新方法がCIサービスごとに違う
特定のブランチのみacheをクリアできない
cacheバージョンファイル
cacheのバージョンになるファイルをコミットして、そのファイルのhashを使う
Pros
更新は簡単
全体での一律管理がでできる
設定ファイルを見れば現在のバージョン状態がわかる
更新方法がわかりやすい
特定のブランチのみcacheをクリアすることが容易
更新方法がCIサービスに依存しない
更新時に特殊な権限を必要としない
Cons
hashを使用するため最終的に展開されるkeyが長くなる
設定ファイルに記述するkeyも長くなる
管理するファイルが増える
cacheバージョンファイルに関しては以下のような内容を使用している。 (hashを使用するため、内容は自由に記述できる)
複数箇所から参照するキャッシュのバージョン生成用ファイル キャッシュの整合性の問題が出た場合に以下の数字を更新する 1
keyとして使用する場合には以下のように記述する。
${{ hashFiles('.github/workflows/cache-version.txt') }}
最終的にkey全体は以下のようになる。 (これより前のstepでnode_versionを定義している)
${{ runner.os }}-v${{ hashFiles('.github/workflows/cache-version.txt') }}-nodemodules-node${{ steps.node_version.outputs.version }}-${{ hashFiles('yarn.lock') }}
1 note
·
View note
Link
https://go.aws/2wZNQ4h - mua hàng trên amazon UniShipping - mua hàng trên ebay UniShipping - mua hàng trên jomashop UniShipping - website mua hàng mỹ UniShipping
0 notes
Text
Probability vs Statistics
Probability and statistics are related areas of mathematics which concern themselves with analyzing the relative frequency of events.
Still, there are fundamental differences in the way they see the world:
Probability deals with predicting the likelihood of future events, while statistics involves the analysis of the frequency of past events.
https://www3.cs.stonybrook.edu/~skiena/jaialai/excerpts/node12.html
0 notes
Text
Glossary
Nominal Ordinal Interval Ratio Random Sampling Sampling Errors Mean Mode Range Variance Standard Deviation Empirical Rule Chebyshev’s Theorem Bayes' Rule Six Sigma Lean Manufacturing Decision Tree Hypothesis Testing Type 1 and Type 2 Errors Regression Analysis Statistic versus Probability
Key TermText Chapter , or onlineDefinitionSourceNominalOnlineNominal basically refers to categorically discrete data such as name of your school, type of car you drive or name of a book. This one is easy to remember because nominal sounds like name (they have the same Latin root). http://www.usablestats.com/lessons/noirOrdinalOnlineOrdinal refers to quantities that have a natural ordering. The ranking of favorite sports, the order of people's place in a line, the order of runners finishing a race or more often the choice on a rating scale from 1 to 5. With ordinal data you cannot state with certainty whether the intervals between each value are equal. For example, we often using rating scales (Likert questions). On a 10 point scale, the difference between a 9 and a 10 is not necessarily the same difference as the difference between a 6 and a 7. This is also an easy one to remember, ordinal sounds like orderhttp://www.usablestats.com/lessons/noirIntervalOnlineInterval data is like ordinal except we can say the intervals between each value are equally split. The most common example is temperature in degrees Fahrenheit. The difference between 29 and 30 degrees is the same magnitude as the difference between 78 and 79 (although I know I prefer the latter). With attitudinal scales and the Likert questions you usually see on a survey, these are rarely interval, although many points on the scale likely are of equal intervals.http://www.usablestats.com/lessons/noirRatioOnlineRatio data is interval data with a natural zero point. For example, time is ratio since 0 time is meaningful. Degrees Kelvin has a 0 point (absolute 0) and the steps in both these scales have the same degree of magnitude.http://www.usablestats.com/lessons/noirRandom SamplingOnlinea random sample is a set of items that have been drawn from a population in such a way that each time an item was selected, every item in the population had an equal opportunity to appear in the sample. In practical terms, it is not so easy to draw a random sample.http://www.animatedsoftware.com/statglos/sgrandsa.htmSamping ErrorsOnlineThat part of the difference between a population value and an estimate thereof, derived from a random sample, which is due to the fact that only a sample of values is observed; as distinct from errors due to imperfect selection, bias in response or estimation, errors of observation and recording, etc. http://stats.oecd.org/glossary/detail.asp?ID=2377MeanOnlinean average; a number that in some sense represents the central value of a set of numbers.https://medical-dictionary.thefreedictionary.com/Mean+(statistics)ModeOnlineThe mode represents the most frequent value in a set of data. For example in the set of data: 3,5,6,7,7,9,8,7,5,6,4,5,3,1 the number 7 is the mode. The mode doesn't have to be the center of a set of data and there can be more than one mode.http://www.usablestats.com/lessons/datacenterRangeOnlinerange is defined simply as the difference between the maximum and minimum observationshttps://explorable.com/range-in-statisticsVarianceOnlineThe variance is a numerical value used to indicate how widely individuals in a group vary. If individual observations vary greatly from the group mean, the variance is big; and vice versa.http://stattrek.com/statistics/dictionary.aspx?definition=VarianceStandard DeviationOnlinea measure of the dispersion of a frequency distribution that is the square root of the arithmetic mean of the squares of the deviation of each of the class frequencies from the arithmetic mean of the frequency distribution; also : a similar quantity found by dividing by one less than the number of squares in the sum of squares instead of taking the arithmetic mean https://www.merriam-webster.com/dictionary/standard%20deviationEmpirical RuleOnlineThe so called empirical rule states that the bulk of the data cluster around the mean in a normal distribution. In fact: 68% of values fall within 1 standard deviation of the mean 95% fall within 2 standard deviations of the mean 99% fall within 3 standard deviations of the meanhttp://www.usablestats.com/lessons/empiricalChebyshev's TheoremOnlineChebyshev’s Theorem tells us that no matter what the distribution looks like, the probability that a randomly selected values is in the intervalhttp://academic.regis.edu/jseibert/SumStat08/Descriptive/DC1-Chebyshev.pdfBay's RuleOnlinea formula that describes how to update the probabilities of hypotheses when given evidence. It follows simply from the axioms of conditional probability, but can be used to powerfully reason about a wide range of problems involving belief updates.https://brilliant.org/wiki/bayes-theorem/Six SigmaOnlineSix Sigma at many organizations simply means a measure of quality that strives for near perfection. Six Sigma is a disciplined, data-driven approach and methodology for eliminating defects (driving toward six standard deviations between the mean and the nearest specification limit) in any process – from manufacturing to transactional and from product to service.https://www.isixsigma.com/new-to-six-sigma/getting-started/what-six-sigma/Lean ManufacturingOnlineThe core idea behind lean manufacturing is maximizing customer value while minimizing waste, thereby achieving manufacturing excellence through the creation of more value with fewer resources.https://www.qualitydigest.com/inside/twitter-ed/introduction-lean-manufacturing.html#Decision TreeOnlineDecision trees are produced by algorithms that identify various ways of splitting a data set into branch-like segments. These segments form an inverted decision tree that originates with a root node at the top of the tree. http://support.sas.com/publishing/pubcat/chaps/57587.pdfHypothesis TestingOnlineProcedure for deciding if a null hypothesis should be accepted or rejected in favor of an alternate hypothesis. A statistic is computed from a survey or test result and is analyzed to determine if it falls within a preset acceptance region. If it does, the null hypothesis is accepted otherwise rejected.http://www.businessdictionary.com/definition/hypothesis-testing.htmlType 1 and Type 2 ErrorsOnlineA type I error (false-positive) occurs if an investigator rejects a null hypothesis that is actually true in the population; a type II error (false-negative) occurs if the investigator fails to reject a null hypothesis that is actually false in the population.https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2996198/Regression AnalysisOnlineRegression is a statistical technique to determine the linear relationship between two or more variables. Regression is primarily used for prediction and causal inference.http://statlab.stat.yale.edu/workshops/IntroRegression/StatLab-IntroRegressionFa08.pdfStatistic versus ProbabilityOnlineProbability and statistics are related areas of mathematics which concern themselves with analyzing the relative frequency of events. Still, there are fundamental differences in the way they see the world: • Probability deals with predicting the likelihood of future events, while statistics involves the analysis of the frequency of past events. • Probability is primarily a theoretical branch of mathematics, which studies the consequences of mathematical definitions. Statistics is primarily an applied branch of mathematics, which tries to make sense of observations in the real world. https://www3.cs.stonybrook.edu/~skiena/jaialai/excerpts/node12.html
0 notes