\href{https://npmjs.org/package/etag}{\texttt{ }} \href{https://npmjs.org/package/etag}{\texttt{ }} \href{https://nodejs.org/en/download/}{\texttt{ }} \href{https://travis-ci.org/jshttp/etag}{\texttt{ }} \href{https://coveralls.io/r/jshttp/etag?branch=master}{\texttt{ }}

Create simple HTTP ETags

This module generates HTTP ETags (as defined in RFC 7232) for use in HTTP responses.\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9276}{}\doxysection{Installation}\label{md_sfcode_node_modules_etag_README_autotoc_md9276}
This is a \href{https://nodejs.org/en/}{\texttt{ Node.\+js}} module available through the \href{https://www.npmjs.com/}{\texttt{ npm registry}}. Installation is done using the \href{https://docs.npmjs.com/getting-started/installing-npm-packages-locally}{\texttt{ {\ttfamily npm install} command}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install etag }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9277}{}\doxysection{API}\label{md_sfcode_node_modules_etag_README_autotoc_md9277}

\begin{DoxyCode}{0}
\DoxyCodeLine{var etag = require('etag') }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9278}{}\doxysubsection{etag(entity, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_etag_README_autotoc_md9278}
Generate a strong ETag for the given entity. This should be the complete body of the entity. Strings, {\ttfamily Buffer}s, and {\ttfamily fs.\+Stats} are accepted. By default, a strong ETag is generated except for {\ttfamily fs.\+Stats}, which will generate a weak ETag (this can be overwritten by {\ttfamily options.\+weak}).


\begin{DoxyCode}{0}
\DoxyCodeLine{res.setHeader('ETag', etag(body)) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9279}{}\doxysubsubsection{Options}\label{md_sfcode_node_modules_etag_README_autotoc_md9279}
{\ttfamily etag} accepts these properties in the options object.\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9280}{}\doxyparagraph{weak}\label{md_sfcode_node_modules_etag_README_autotoc_md9280}
Specifies if the generated ETag will include the weak validator mark (that is, the leading {\ttfamily W/}). The actual entity tag is the same. The default value is {\ttfamily false}, unless the {\ttfamily entity} is {\ttfamily fs.\+Stats}, in which case it is {\ttfamily true}.\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9281}{}\doxysection{Testing}\label{md_sfcode_node_modules_etag_README_autotoc_md9281}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm test }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9282}{}\doxysection{Benchmark}\label{md_sfcode_node_modules_etag_README_autotoc_md9282}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm run-\/script bench}
\DoxyCodeLine{}
\DoxyCodeLine{> etag@1.8.1 bench nodejs-\/etag}
\DoxyCodeLine{> node benchmark/index.js}
\DoxyCodeLine{}
\DoxyCodeLine{  http\_parser@2.7.0}
\DoxyCodeLine{  node@6.11.1}
\DoxyCodeLine{  v8@5.1.281.103}
\DoxyCodeLine{  uv@1.11.0}
\DoxyCodeLine{  zlib@1.2.11}
\DoxyCodeLine{  ares@1.10.1-\/DEV}
\DoxyCodeLine{  icu@58.2}
\DoxyCodeLine{  modules@48}
\DoxyCodeLine{  openssl@1.0.2k}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/body0-\/100b.js}
\DoxyCodeLine{}
\DoxyCodeLine{  100B body}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  buffer -\/ strong x 258,647 ops/sec ±1.07\% (180 runs sampled)}
\DoxyCodeLine{  buffer -\/ weak   x 263,812 ops/sec ±0.61\% (184 runs sampled)}
\DoxyCodeLine{  string -\/ strong x 259,955 ops/sec ±1.19\% (185 runs sampled)}
\DoxyCodeLine{  string -\/ weak   x 264,356 ops/sec ±1.09\% (184 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/body1-\/1kb.js}
\DoxyCodeLine{}
\DoxyCodeLine{  1KB body}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  buffer -\/ strong x 189,018 ops/sec ±1.12\% (182 runs sampled)}
\DoxyCodeLine{  buffer -\/ weak   x 190,586 ops/sec ±0.81\% (186 runs sampled)}
\DoxyCodeLine{  string -\/ strong x 144,272 ops/sec ±0.96\% (188 runs sampled)}
\DoxyCodeLine{  string -\/ weak   x 145,380 ops/sec ±1.43\% (187 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/body2-\/5kb.js}
\DoxyCodeLine{}
\DoxyCodeLine{  5KB body}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  buffer -\/ strong x 92,435 ops/sec ±0.42\% (188 runs sampled)}
\DoxyCodeLine{  buffer -\/ weak   x 92,373 ops/sec ±0.58\% (189 runs sampled)}
\DoxyCodeLine{  string -\/ strong x 48,850 ops/sec ±0.56\% (186 runs sampled)}
\DoxyCodeLine{  string -\/ weak   x 49,380 ops/sec ±0.56\% (190 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/body3-\/10kb.js}
\DoxyCodeLine{}
\DoxyCodeLine{  10KB body}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  buffer -\/ strong x 55,989 ops/sec ±0.93\% (188 runs sampled)}
\DoxyCodeLine{  buffer -\/ weak   x 56,148 ops/sec ±0.55\% (190 runs sampled)}
\DoxyCodeLine{  string -\/ strong x 27,345 ops/sec ±0.43\% (188 runs sampled)}
\DoxyCodeLine{  string -\/ weak   x 27,496 ops/sec ±0.45\% (190 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/body4-\/100kb.js}
\DoxyCodeLine{}
\DoxyCodeLine{  100KB body}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  buffer -\/ strong x 7,083 ops/sec ±0.22\% (190 runs sampled)}
\DoxyCodeLine{  buffer -\/ weak   x 7,115 ops/sec ±0.26\% (191 runs sampled)}
\DoxyCodeLine{  string -\/ strong x 3,068 ops/sec ±0.34\% (190 runs sampled)}
\DoxyCodeLine{  string -\/ weak   x 3,096 ops/sec ±0.35\% (190 runs sampled)}
\DoxyCodeLine{}
\DoxyCodeLine{> node benchmark/stats.js}
\DoxyCodeLine{}
\DoxyCodeLine{  stat}
\DoxyCodeLine{}
\DoxyCodeLine{  4 tests completed.}
\DoxyCodeLine{}
\DoxyCodeLine{  real -\/ strong x 871,642 ops/sec ±0.34\% (189 runs sampled)}
\DoxyCodeLine{  real -\/ weak   x 867,613 ops/sec ±0.39\% (190 runs sampled)}
\DoxyCodeLine{  fake -\/ strong x 401,051 ops/sec ±0.40\% (189 runs sampled)}
\DoxyCodeLine{  fake -\/ weak   x 400,100 ops/sec ±0.47\% (188 runs sampled) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_etag_README_autotoc_md9283}{}\doxysection{License}\label{md_sfcode_node_modules_etag_README_autotoc_md9283}
\mbox{[}MIT\mbox{]}(LICENSE) 