Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
JavaScript funzionalità di runtime 2.0 per CloudFront Functions
L'ambiente JavaScript di runtime di CloudFront Functions è conforme alla versione 5.1 ECMAScript (ES)
Argomenti
Caratteristiche principali
Sono supportate le seguenti caratteristiche principali di ES.
- Tipi
-
Sono supportati tutti i tipi ES 5.1. Tra questi vi sono valori booleani, numeri, stringhe, oggetti, matrici, funzioni ed espressioni regolari.
- Operatori
-
Sono supportati tutti gli operatori ES 5.1.
È supportato l'operatore esponenziale ES 7 (
**
). - Dichiarazioni
-
Sono supportate le seguenti istruzioni ES 5.1:
-
break
-
catch
-
continue
-
do-while
-
else
-
finally
-
for
-
for-in
-
if
-
label
-
return
-
switch
-
throw
-
try
-
var
-
while
Sono supportate le seguenti istruzioni ES 6:
async
-
await
-
const
-
let
Nota
async
,await
const
, elet
sono supportati nel JavaScript runtime 2.0.await
possono essere utilizzati solo all'internoasync
delle funzioni.async
argomenti e chiusure non sono supportati.
-
- Valori letterali
-
Sono supportati i valori letterali modello ES 6: stringhe multilinea, interpolazione di espressioni e modelli di nidificazione.
- Funzioni
-
Sono supportate tutte le funzioni ES 5.1.
Sono supportate le funzioni freccia ES 6 ed è supportata la sintassi del parametro rest ES 6.
- Unicode
-
Il testo di origine e i valori letterali stringa possono contenere caratteri codificati in Unicode. Sono supportate anche sequenze di escape dei punti di codice Unicode di sei caratteri (ad esempio,
\uXXXX
). - Modalità rigorosa
-
Le funzioni funzionano in modalità rigorosa per impostazione predefinita, quindi non è necessario aggiungere una istruzione
use strict
nel codice funzione. Non possono essere modificate.
Oggetti primitivi
Sono supportati i seguenti oggetti primitivi di ES.
- Oggetto
-
Sono supportati i seguenti metodi ES 5.1 sugli oggetti:
-
Object.create()
(senza elenco delle proprietà) -
Object.defineProperties()
-
Object.defineProperty()
-
Object.freeze()
-
Object.getOwnPropertyDescriptor()
-
Object.getOwnPropertyDescriptors()
-
Object.getOwnPropertyNames()
-
Object.getPrototypeOf()
-
Object.isExtensible()
-
Object.isFrozen()
-
Object.isSealed()
-
Object.keys()
-
Object.preventExtensions()
-
Object.seal()
Sono supportati i seguenti metodi ES 6 sugli oggetti:
-
Object.assign()
Sono supportati i seguenti metodi ES 8 sugli oggetti:
-
Object.entries()
-
Object.values()
Sono supportati i seguenti metodi di prototipo ES 5.1 sugli oggetti:
-
Object.prototype.hasOwnProperty()
-
Object.prototype.isPrototypeOf()
-
Object.prototype.propertyIsEnumerable()
-
Object.prototype.toString()
-
Object.prototype.valueOf()
Sono supportati i seguenti metodi di prototipo ES 6 sugli oggetti:
-
Object.prototype.is()
-
Object.prototype.setPrototypeOf()
-
- Stringa
-
Sono supportati i seguenti metodi ES 5.1 sulle stringhe:
String.fromCharCode()
Sono supportati i seguenti metodi ES 6 sulle stringhe:
String.fromCodePoint()
Sono supportati i seguenti metodi di prototipo ES 5.1 sulle stringhe:
-
String.prototype.charAt()
-
String.prototype.concat()
-
String.prototype.indexOf()
-
String.prototype.lastIndexOf()
-
String.prototype.match()
-
String.prototype.replace()
-
String.prototype.search()
-
String.prototype.slice()
-
String.prototype.split()
-
String.prototype.substr()
-
String.prototype.substring()
-
String.prototype.toLowerCase()
-
String.prototype.trim()
-
String.prototype.toUpperCase()
Sono supportati i seguenti metodi di prototipo ES 6 sulle stringhe:
-
String.prototype.codePointAt()
-
String.prototype.endsWith()
-
String.prototype.includes()
-
String.prototype.repeat()
-
String.prototype.startsWith()
Sono supportati i seguenti metodi di prototipo ES 8 sulle stringhe:
-
String.prototype.padStart()
-
String.prototype.padEnd()
Sono supportati i seguenti metodi di prototipo ES 9 sulle stringhe:
-
String.prototype.trimStart()
-
String.prototype.trimEnd()
Sono supportati i seguenti metodi di prototipo ES 12 sulle stringhe:
String.prototype.replaceAll()
Nota
String.prototype.replaceAll()
è nuovo in JavaScript runtime 2.0.
- Numero
-
Sono supportati TUTTI i numeri ES 5.
Sono supportate le seguenti proprietà ES 6 sui numeri:
Number.EPSILON
-
Number.MAX_SAFE_INTEGER
-
Number.MIN_SAFE_INTEGER
-
Number.MAX_VALUE
-
Number.MIN_VALUE
-
Number.NaN
-
Number.NEGATIVE_INFINITY
-
Number.POSITIVE_INFINITY
Sono supportati i seguenti metodi ES 6 sui numeri:
-
Number.isFinite()
-
Number.isInteger()
-
Number.isNaN()
-
Number.isSafeInteger()
-
Number.parseInt()
-
Number.parseFloat()
Sono supportati i seguenti metodi di prototipo ES 5.1 sui numeri:
-
Number.prototype.toExponential()
-
Number.prototype.toFixed()
-
Number.prototype.toPrecision()
Sono supportati i separatori numerici ES 12.
Nota
I separatori numerici ES 12 sono nuovi nel JavaScript runtime 2.0.
Oggetti incorporati
Sono supportati i seguenti oggetti incorporati di ES.
- Math
-
Sono supportati tutti i metodi matematici ES 5.1.
Nota
Nell'ambiente di runtime di CloudFront Functions, l'
Math.random()
implementazione utilizzaarc4random
OpenBSD con il timestamp di quando la funzione viene eseguita.Sono supportate le seguenti proprietà matematiche ES 6:
-
Math.E
-
Math.LN10
-
Math.LN2
-
Math.LOG10E
-
Math.LOG2E
-
Math.PI
-
Math.SQRT1_2
-
Math.SQRT2
Sono supportati i seguenti metodi matematici ES 6:
-
Math.abs()
-
Math.acos()
-
Math.acosh()
-
Math.asin()
-
Math.asinh()
-
Math.atan()
-
Math.atan2()
-
Math.atanh()
-
Math.cbrt()
-
Math.ceil()
-
Math.clz32()
-
Math.cos()
-
Math.cosh()
-
Math.exp()
-
Math.expm1()
-
Math.floor()
-
Math.fround()
-
Math.hypot()
-
Math.imul()
-
Math.log()
-
Math.log1p()
-
Math.log2()
-
Math.log10()
-
Math.max()
-
Math.min()
-
Math.pow()
-
Math.random()
-
Math.round()
-
Math.sign()
-
Math.sinh()
-
Math.sin()
-
Math.sqrt()
-
Math.tan()
-
Math.tanh()
-
Math.trunc()
-
- Data
-
Sono supportate tutte le funzioni
Date
ES 5.1.Nota
Per motivi di sicurezza, restituisce
Date
sempre lo stesso valore, ovvero l'ora di inizio della funzione, durante la durata di una singola esecuzione di una funzione. Per ulteriori informazioni, consulta Funzionalità con restrizioni. - Funzione
-
Sono supportati i seguenti metodi di prototipo ES 5.1:
Function.prototype.apply()
-
Function.prototype.bind()
-
Function.prototype.call()
I costruttori di funzioni non sono supportati.
- Espressioni regolari
-
Sono supportate tutte le funzioni di espressione regolare ES 5.1. Il linguaggio delle espressioni regolari è compatibile con Perl.
Sono supportate le seguenti proprietà di accessor per prototipo ES 5.1:
-
RegExp.prototype.global
-
RegExp.prototype.ignoreCase
-
RegExp.protoype.multiline
-
RegExp.protoype.source
-
RegExp.prototype.sticky
-
RegExp.prototype.flags
Nota
RegExp.prototype.sticky
eRegExp.prototype.flags
sono nuove in runtime 2.0. JavaScript
Sono supportati i seguenti metodi di prototipo ES 5.1:
-
RegExp.prototype.exec()
-
RegExp.prototype.test()
-
RegExp.prototype.toString()
-
RegExp.prototype[@@replace]()
-
RegExp.prototype[@@split]()
Nota
RegExp.prototype[@@split]()
sono nuove nel JavaScript runtime 2.0.
Sono supportate le seguenti proprietà di istanza ES 5.1:
-
lastIndex
Sono supportati i gruppi di acquisizione denominati di ES 9.
-
- JSON
-
Sono supportati i seguenti metodi ES 5.1:
-
JSON.parse()
-
JSON.stringify()
-
- Array
-
Sono supportati i seguenti metodi ES 5.1 sugli array:
-
Array.isArray()
Sono supportati i seguenti metodi ES 6 sugli array:
-
Array.of()
Sono supportati i seguenti metodi di prototipo ES 5.1:
-
Array.prototype.concat()
-
Array.prototype.every()
-
Array.prototype.filter()
-
Array.prototype.forEach()
-
Array.prototype.indexOf()
-
Array.prototype.join()
-
Array.prototype.lastIndexOf()
-
Array.prototype.map()
-
Array.prototype.pop()
-
Array.prototype.push()
-
Array.prototype.reduce()
-
Array.prototype.reduceRight()
-
Array.prototype.reverse()
-
Array.prototype.shift()
-
Array.prototype.slice()
-
Array.prototype.some()
-
Array.prototype.sort()
-
Array.prototype.splice()
-
Array.prototype.unshift()
Sono supportati i seguenti metodi di prototipo ES 6:
-
Array.prototype.copyWithin()
-
Array.prototype.fill()
-
Array.prototype.find()
-
Array.prototype.findIndex()
Sono supportati i seguenti metodi di prototipo ES 7:
Array.prototype.includes()
-
- Array tipizzati
-
Sono supportati i seguenti costruttori di array tipizzati ES 6:
-
Float32Array
-
Float64Array
-
Int8Array
-
Int16Array
-
Int32Array
-
Uint8Array
-
Uint8ClampedArray
-
Uint16Array
-
Uint32Array
Sono supportati i seguenti metodi ES 6:
-
TypedArray.from()
-
TypedArray.of()
Nota
TypedArray.from()
eTypedArray.of()
sono nuove nel JavaScript runtime 2.0.
Sono supportati i seguenti metodi di prototipo ES 6:
-
TypedArray.prototype.copyWithin()
-
TypedArray.prototype.every()
-
TypedArray.prototype.fill()
-
TypedArray.prototype.filter()
-
TypedArray.prototype.find()
-
TypedArray.prototype.findIndex()
-
TypedArray.prototype.forEach()
-
TypedArray.prototype.includes()
-
TypedArray.prototype.indexOf()
-
TypedArray.prototype.join()
-
TypedArray.prototype.lastIndexOf()
-
TypedArray.prototype.map()
-
TypedArray.prototype.reduce()
-
TypedArray.prototype.reduceRight()
-
TypedArray.prototype.reverse()
-
TypedArray.prototype.some()
-
TypedArray.prototype.set()
-
TypedArray.prototype.slice()
-
TypedArray.prototype.sort()
-
TypedArray.prototype.subarray()
-
TypedArray.prototype.toString()
Nota
TypedArray.prototype.every()
,TypedArray.prototype.fill()
,TypedArray.prototype.filter()
,TypedArray.prototype.find()
,TypedArray.prototype.findIndex()
TypedArray.prototype.forEach()
,TypedArray.prototype.includes()
,TypedArray.prototype.indexOf()
,TypedArray.prototype.join()
,TypedArray.prototype.lastIndexOf()
,TypedArray.prototype.map()
,TypedArray.prototype.reduce()
,TypedArray.prototype.reduceRight()
TypedArray.prototype.reverse()
, eTypedArray.prototype.some()
sono nuovi nel JavaScript runtime 2.0.
-
- ArrayBuffer
-
Sono supportati i seguenti metodi ES 6 su ArrayBuffer :
-
isView()
Sono supportati i seguenti metodi prototipali ES 6 su ArrayBuffer :
-
ArrayBuffer.prototype.slice()
-
- Promessa
-
Sono supportati i seguenti metodi ES 6 sulle promesse:
-
Promise.all()
-
Promise.allSettled()
-
Promise.any()
-
Promise.reject()
-
Promise.resolve()
-
Promise.race()
Nota
Promise.all()
,Promise.allSettled()
Promise.any()
, ePromise.race()
sono nuovi nel JavaScript runtime 2.0.
Sono supportati i seguenti metodi di prototipo ES 6 sulle promesse:
-
Promise.prototype.catch()
-
Promise.prototype.finally()
-
Promise.prototype.then()
-
- DataView
-
Sono supportati i seguenti metodi di prototipo ES 6:
-
DataView.prototype.getFloat32()
-
DataView.prototype.getFloat64()
-
DataView.prototype.getInt16()
-
DataView.prototype.getInt32()
-
DataView.prototype.getInt8()
-
DataView.prototype.getUint16()
-
DataView.prototype.getUint32()
-
DataView.prototype.getUint8()
-
DataView.prototype.setFloat32()
-
DataView.prototype.setFloat64()
-
DataView.prototype.setInt16()
-
DataView.prototype.setInt32()
-
DataView.prototype.setInt8()
-
DataView.prototype.setUint16()
-
DataView.prototype.setUint32()
-
DataView.prototype.setUint8()
Nota
Tutti i metodi prototipali di Dataview ES 6 sono nuovi in JavaScript runtime 2.0.
-
- Symbol
-
Sono supportati i seguenti metodi ES 6:
-
Symbol.for()
-
Symbol.keyfor()
Nota
Tutti i metodi Symbol ES 6 sono nuovi nel JavaScript runtime 2.0.
-
- TextDecoder
-
Sono supportati i seguenti metodi di prototipo:
-
TextDecoder.prototype.decode()
Sono supportate le seguenti proprietà di accessor per prototipo:
-
TextDecoder.prototype.encoding
-
TextDecoder.prototype.fatal
-
TextDecoder.prototype.ignoreBOM
-
- TextEncoder
-
Sono supportati i seguenti metodi di prototipo:
-
TextEncoder.prototype.encode()
-
TextEncoder.prototype.encodeInto()
-
Tipi di errore
Sono supportati i seguenti oggetti di errore:
-
Error
-
EvalError
-
InternalError
-
RangeError
-
ReferenceError
-
SyntaxError
-
TypeError
-
URIError
Elementi globali
L'oggetto globalThis
è supportato.
Sono supportate le seguenti funzioni globali ES 5.1:
-
decodeURI()
-
decodeURIComponent()
-
encodeURI()
-
encodeURIComponent()
-
isFinite()
-
isNaN()
-
parseFloat()
-
parseInt()
Sono supportate le seguenti funzioni globali ES 6:
atob()
-
btoa()
Nota
atob()
ebtoa()
sono nuovi nel JavaScript runtime 2.0.
Sono supportate le seguenti costanti globali:
-
NaN
-
Infinity
-
undefined
-
arguments
Moduli incorporati
Sono supportati i seguenti moduli incorporati:
Buffer
Il modulo fornisce i metodi seguenti:
-
Buffer.alloc(size[, fill[, encoding]])
Alloca un
Buffer
.-
size
: dimensione del buffer. Immetti un numero intero. -
fill
: facoltativo. Immetti una stringa,Buffer
, Uint8Array o un numero intero. Il valore predefinito è0
. -
encoding
: facoltativo. Quandofill
è una stringa, immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
-
Buffer.allocUnsafe(size)
Alloca un
Buffer
non inizializzato.-
size
: immetti un numero intero.
-
-
Buffer.byteLength(value[, encoding])
Restituisce la lunghezza di un valore, in byte.
-
value
: Una stringa,Buffer
TypedArray, Dataview o Arraybuffer. -
encoding
: facoltativo. Quandovalue
è una stringa, immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
-
Buffer.compare(buffer1, buffer2)
Confronta due
Buffer
per semplificare l'ordinamento degli array. Restituisce0
se sono uguali,-1
se viene primabuffer1
o1
se viene primabuffer2
.-
buffer1
: immetti unBuffer
. -
buffer2
: immetti un altroBuffer
.
-
-
Buffer.concat(list[, totalLength])
Concatena più
Buffer
. Restituisce0
se non ce ne sono. Restituisce fino atotalLength
.-
list
: immetti un elenco diBuffer
. Tieni presente che verrà troncato atotalLength
. -
totalLength
: facoltativo. Inserisci un numero intero senza segno. Usa la somma delle istanzeBuffer
nell'elenco se vuoto.
-
-
Buffer.from(array)
Crea un
Buffer
da un array.-
array
: immetti un array di byte da0
a255
.
-
-
Buffer.from(arrayBuffer, byteOffset[, length]))
Crea una vista da
arrayBuffer
, partendo dall'offsetbyteOffset
con lunghezzalength
.-
arrayBuffer
: immetti una matriceBuffer
. -
byteOffset
: immetti un numero intero. -
length
: facoltativo. Immetti un numero intero.
-
-
Buffer.from(buffer)
Crea una copia del
Buffer
.-
buffer
: immetti unBuffer
.
-
-
Buffer.from(object[, offsetOrEncoding[, length]])
Crea un
Buffer
da un oggetto. RestituisceBuffer.from(object.valueOf(), offsetOrEncoding, length)
sevalueOf()
non è uguale all'oggetto.-
object
: immetti un oggetto. -
offsetOrEncoding
: facoltativo. Immetti un numero intero o una stringa di codifica. -
length
: facoltativo. Immetti un numero intero.
-
-
Buffer.from(string[, encoding])
Crea un
Buffer
da una stringa.-
string
: immetti una stringa. -
encoding
: facoltativo. Immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
-
Buffer.isBuffer(object)
Controlla se
object
è un buffer. Restituiscetrue
ofalse
.-
object
: immetti un oggetto.
-
-
Buffer.isEncoding(encoding)
Verifica se
encoding
è supportato. Restituiscetrue
ofalse
.-
encoding
: facoltativo. Immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
Il modulo fornisce i seguenti metodi di prototipo del buffer:
-
Buffer.prototype.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]])
Confronta
Buffer
con l'obiettivo. Restituisce0
se sono uguali,1
se viene primabuffer
o-1
se viene primatarget
.-
target
: immetti unBuffer
. -
targetStart
: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
targetEnd
: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza ditarget
. -
sourceStart
: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
sourceEnd
: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza diBuffer
.
-
-
Buffer.prototype.copy(target[, targetStart[, sourceStart[, sourceEnd]]])
Copia il buffer su
target
.-
target
: immetti unBuffer
oUint8Array
. -
targetStart
: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
sourceStart
: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
sourceEnd
: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza diBuffer
.
-
-
Buffer.prototype.equals(otherBuffer)
Confronta
Buffer
conotherBuffer
. Restituiscetrue
ofalse
.-
otherBuffer
: immetti una stringa.
-
-
Buffer.prototype.fill(value[, offset[, end][, encoding])
Compila
Buffer
convalue
.-
value
: immetti una stringa,Buffer
o un numero intero. -
offset
: facoltativo. Immetti un numero intero. -
end
: facoltativo. Immetti un numero intero. -
encoding
: facoltativo. Immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
-
Buffer.prototype.includes(value[, byteOffset][, encoding])
Cerca
value
inBuffer
. Restituiscetrue
ofalse
.-
value
: immetti una stringa,Buffer
,Uint8Array
o un numero intero. -
byteOffset
: facoltativo. Immetti un numero intero. -
encoding
: facoltativo. Immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
-
Buffer.prototype.indexOf(value[, byteOffset][, encoding])
Cerca il primo
value
inBuffer
. Restituisceindex
se trovato e-1
se non trovato.-
value
: immetti una stringa,Buffer
, Unit8Array o un numero intero compreso tra 0 e 255. -
byteOffset
: facoltativo. Immetti un numero intero. -
encoding
: facoltativo. Sevalue
è una stringa, immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
-
Buffer.prototype.lastIndexOf(value[, byteOffset][, encoding])
Cerca l'ultimo
value
inBuffer
. Restituisceindex
se trovato e-1
se non trovato.-
value
: immetti una stringa,Buffer
, Unit8Array o un numero intero compreso tra 0 e 255. -
byteOffset
: facoltativo. Immetti un numero intero. -
encoding
: facoltativo. Sevalue
è una stringa, immetti uno dei seguenti valori:utf8
,hex
,base64
,base64url
. Il valore predefinito èutf8
.
-
-
Buffer.prototype.readInt8(offset)
Leggi
Int8
inoffset
a partire daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readIntBE(offset, byteLength)
Leggi
Int
come big-endian inoffset
daBuffer
.-
offset
: immetti un numero intero. -
byteLength
: facoltativo. Immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.readInt16BE(offset)
Leggi
Int16
come big-endian inoffset
daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readInt32BE(offset)
Leggi
Int32
come big-endian inoffset
daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readIntLE(offset, byteLength)
Leggi
Int
come little-endian inoffset
daBuffer
.-
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.readInt16LE(offset)
Leggi
Int16
come little-endian inoffset
daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readInt32LE(offset)
Leggi
Int32
come little-endian inoffset
daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readUInt8(offset)
Leggi
UInt8
inoffset
a partire daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readUIntBE(offset, byteLength)
Leggi
UInt
come big-endian inoffset
daBuffer
.-
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.readUInt16BE(offset)
Leggi
UInt16
come big-endian inoffset
daBuffer
. -
-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readUInt32BE(offset)
Leggi
UInt32
come big-endian inoffset
daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readUIntLE(offset, byteLength)
Leggi
UInt
come little-endian inoffset
daBuffer
.-
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.readUInt16LE(offset)
Leggi
UInt16
come little-endian inoffset
daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readUInt32LE(offset)
Leggi
UInt32
come little-endian inoffset
daBuffer
.-
offset
: immetti un numero intero.
-
-
Buffer.prototype.readDoubleBE([offset])
Leggi un file a doppia precisione a 64 bit come big-endian in
offset
daBuffer
.-
offset
: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.readDoubleLE([offset])
Leggi un file a doppia precisione a 64 bit come little-endian in
offset
daBuffer
.-
offset
: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.readFloatBE([offset])
Leggi un file a virgola mobile a 32 bit come big-endian in
offset
daBuffer
.-
offset
: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.readFloatLE([offset])
Leggi un file a virgola mobile a 32 bit come little-endian in
offset
daBuffer
.-
offset
: facoltativo. Immetti un numero intero.
-
-
Buffer.prototype.subarray([start[, end]])
Restituisce una copia di
Buffer
con offset e ritaglio con nuovi valori perstart
eend
.-
start
: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
end
: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza del buffer.
-
-
Buffer.prototype.swap16()
Scambia l'ordine dei byte dell'array
Buffer
, trattandolo come un array di numeri a 16 bit. La lunghezza diBuffer
deve essere divisibile per 2, altrimenti riceverai un errore. -
Buffer.prototype.swap32()
Scambia l'ordine dei byte dell'array
Buffer
, trattandolo come un array di numeri a 32 bit. La lunghezza diBuffer
deve essere divisibile per 4, altrimenti riceverai un errore. -
Buffer.prototype.swap64()
Scambia l'ordine dei byte dell'array
Buffer
, trattandolo come un array di numeri a 64 bit. La lunghezza diBuffer
deve essere divisibile per 8, altrimenti riceverai un errore. -
Buffer.prototype.toJSON()
Restituisce
Buffer
come file JSON. -
Buffer.prototype.toString([encoding[, start[, end]]])
Converti
Buffer
, dastart
aend
, in una stringa codificata.-
encoding
: facoltativo. Immetti uno dei seguenti valori:utf8
,hex
,base64
obase64url
. Il valore predefinito èutf8
. -
start
: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
end
: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza del buffer.
-
-
Buffer.prototype.write(string[, offset[, length]][, encoding])
Scrivi il valore
string
codificato suBuffer
se c'è spazio a sufficienza o un valorestring
troncato se non c'è abbastanza spazio.-
string
: immetti una stringa. -
offset
: facoltativo. Immetti un numero intero. Il valore predefinito è 0. -
length
: facoltativo. Immetti un numero intero. Il valore predefinito è la lunghezza della stringa. -
encoding
: facoltativo. Facoltativamente, immetti uno dei seguenti valori:utf8
,hex
,base64
obase64url
. Il valore predefinito èutf8
.
-
-
Buffer.prototype.writeInt8(value, offset, byteLength)
Scrivi
Int8
value
dibyteLength
aoffset
suBuffer
.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeIntBE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeInt16BE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeInt32BE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeIntLE(offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeInt16LE(offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeInt32LE(offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeUInt8(value, offset, byteLength)
Scrivi
UInt8
value
dibyteLength
aoffset
suBuffer
.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeUIntBE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeUInt16BE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeUInt32BE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeUIntLE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeUInt16LE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeUInt32LE(value, offset, byteLength)
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
value
: immetti un numero intero. -
offset
: immetti un numero intero. -
byteLength
: immetti un numero intero compreso tra1
e6
.
-
-
Buffer.prototype.writeDoubleBE(value, [offset])
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
-
Buffer.prototype.writeDoubleLE(value, [offset])
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
value
: immetti un numero intero. -
offset
: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
-
Buffer.prototype.writeFloatBE(value, [offset])
Scrivi
value
aoffset
suBuffer
, usando il metodo big-endian.-
value
: immetti un numero intero. -
offset
: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
-
Buffer.prototype.writeFloatLE(value, [offset])
Scrivi
value
aoffset
suBuffer
, usando il metodo little-endian.-
value
: immetti un numero intero. -
offset
: facoltativo. Immetti un numero intero. Il valore predefinito è 0.
-
Sono supportati i seguenti metodi di istanza:
-
buffer[index]
Ottieni e imposta l'ottetto (byte) a
index
inBuffer
.-
Ottieni un numero da
0
a255
. In alternativa, imposta un numero da0
a255
.
-
Sono supportate le seguenti proprietà di istanza:
-
buffer
Ottieni l'oggetto
ArrayBuffer
per il buffer. -
byteOffset
Ottieni il valore
byteOffset
per l'oggettoArraybuffer
del buffer. -
length
Ottieni il conteggio dei byte del buffer.
Nota
Tutti i metodi del modulo Buffer sono nuovi in runtime 2.0. JavaScript
Stringa di query
Nota
L'oggetto evento CloudFront Functions analizza automaticamente le stringhe di query URL per voi. Ciò significa che nella maggior parte dei casi non è necessario utilizzare questo modulo.
Il modulo stringa di query (querystring
) fornisce metodi per l'analisi e la formattazione delle stringhe di query URL. È possibile caricare il modulo usando require('querystring')
. Il modulo fornisce i metodi seguenti:
querystring.escape(string)
-
URL che codifica il dato
string
, restituendo una stringa di query con escape. Il metodo viene utilizzato daquerystring.stringify()
e non deve essere utilizzato direttamente. querystring.parse(string[, separator[, equal[, options]]])
-
Analizza una stringa di query (
string
) e restituisce un oggetto.Il parametro
separator
è una sottostringa per delimitare coppie chiave e valore nella stringa di query. Per impostazione predefinita, tale valore è&
.Il parametro
equal
è una sottostringa per la delimitazione di chiavi e valori nella stringa di query. Per impostazione predefinita, tale valore è=
.Il parametro
options
è un oggetto con le seguenti chiavi:decodeURIComponent function
-
Un funzione per decodificare i caratteri codificati in percentuale nella stringa di query. Per impostazione predefinita, tale valore è
querystring.unescape()
. maxKeys number
-
Il numero massimo di chiavi da analizzare. Per impostazione predefinita, tale valore è
1000
. Utilizza un valore0
per rimuovere le limitazioni per il conteggio delle chiavi.
Per impostazione predefinita, si presuppone che i caratteri con codifica in percentuale all'interno della stringa di query utilizzino la codifica UTF-8. Le sequenze UTF-8 non valide vengono sostituite con il carattere sostitutivo
U+FFFD
.Ad esempio, per la seguente stringa di query:
'name=value&abc=xyz&abc=123'
Il valore restituito di
querystring.parse()
è:{ name: 'value', abc: ['xyz', '123'] }
querystring.decode()
è un alias perquerystring.parse()
. querystring.stringify(object[, separator[, equal[, options]]])
-
Serializza un
object
e restituisce una stringa di query.Il parametro
separator
è una sottostringa per delimitare coppie chiave e valore nella stringa di query. Per impostazione predefinita, tale valore è&
.Il parametro
equal
è una sottostringa per la delimitazione di chiavi e valori nella stringa di query. Per impostazione predefinita, tale valore è=
.Il parametro
options
è un oggetto con le seguenti chiavi:encodeURIComponent function
-
La funzione da utilizzare per convertire caratteri non sicuri dell’URL in codifica percentuale nella stringa di query. Per impostazione predefinita, tale valore è
querystring.escape()
.
Per impostazione predefinita, i caratteri che richiedono la codifica percentuale all'interno della stringa di query sono codificati come UTF-8. Per utilizzare una codifica diversa, specifica l'opzione
encodeURIComponent
.Ad esempio, per il seguente codice:
querystring.stringify({ name: 'value', abc: ['xyz', '123'], anotherName: '' });
Il valore restituito è:
'name=value&abc=xyz&abc=123&anotherName='
querystring.encode()
è un alias perquerystring.stringify()
. querystring.unescape(string)
-
Decodifica i caratteri codificati in percentuale URL nel dato
string
, restituendo una stringa di query senza escape. Questo metodo viene utilizzato daquerystring.parse()
e non deve essere utilizzato direttamente.
Crittografia
Il modulo di crittografia (crypto
) fornisce helper di hashing standard e HMAC (Hash Message Authentication Code). È possibile caricare il modulo usando require('crypto')
.
Metodi di hashing
crypto.createHash(algorithm)
-
Crea e restituisce un oggetto hash che è possibile utilizzare per generare digest hash utilizzando il dato algoritmo:
md5
,sha1
, osha256
. hash.update(data)
-
Aggiorna il contenuto hash con il dato
data
. hash.digest([encoding])
-
Calcola il digest di tutti i dati passati tramite
hash.update()
. La codifica può esserehex
,base64
obase64url
.
Metodi HMAC
crypto.createHmac(algorithm, secret key)
-
Crea e restituisce un oggetto HMAC che utilizza il dato
algorithm
esecret key
. L'algoritmo può esseremd5
,sha1
osha256
. hmac.update(data)
-
Aggiorna il contenuto HMAC con il dato
data
. hmac.digest([encoding])
-
Calcola il digest di tutti i dati passati tramite
hmac.update()
. La codifica può esserehex
,base64
obase64url
.
Funzionalità con restrizioni
Le seguenti funzionalità JavaScript linguistiche non sono supportate o sono limitate a causa di problemi di sicurezza.
- Valutazione dinamica del codice
-
La valutazione dinamica del codice non è supportata. Entrambi i costruttori
eval()
eFunction
generano un errore se tentato. Ad esempio,const sum = new Function('a', 'b', 'return a + b')
genera un errore. - Timer
-
Le funzioni
setTimeout()
,setImmediate()
eclearTimeout()
non sono supportate. Non vi è alcuna disposizione per differire o cedere all'interno di un'esecuzione di funzione. La funzione deve essere eseguita in modo sincrono fino al completamento. - Data e timestamp
-
Per motivi di sicurezza, non è possibile accedere ai timer ad alta risoluzione. Tutti i metodi
Date
per interrogare l'ora corrente restituiscono sempre lo stesso valore durante la durata di una singola esecuzione di funzione. Il timestamp restituito è il momento in cui la funzione ha iniziato l'esecuzione. Di conseguenza, non è possibile misurare il tempo trascorso nella vostra funzione. - Accesso al file system
-
Nessun accesso al file system. Ad esempio, non esiste un modulo
fs
per l'accesso al file system come invece è presente in Node.js. - Accesso ai processi
-
Non è disponibile alcun accesso al processo. Ad esempio, non esiste un oggetto
process
globale per l'elaborazione dell'accesso alle informazioni come in Node.js. - Variabili di ambiente
-
Non è possibile accedere alle variabili di ambiente. Puoi invece utilizzarlo CloudFront KeyValueStore per creare un datastore centralizzato di coppie chiave-valore per le tue funzioni. CloudFront CloudFront KeyValueStore consente aggiornamenti dinamici ai dati di configurazione senza dover implementare modifiche al codice. Per ulteriori informazioni, consulta Amazon CloudFront KeyValueStore.
- Accesso alla rete
-
Non è disponibile alcun supporto per le chiamate di rete. Ad esempio, XHR, HTTP(S) e socket non sono supportati.