Files
CocosCreatorTutorial/npmPlugin/assets/InportNpm.js
2022-01-11 21:50:28 +08:00

47 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const SHA1 = require('crypto-js').SHA1;
const zlib = require('zlib');
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start() {
let str = SHA1("aaaaaa").toString(); // 计算SHA1值并返回字符串内容
console.log('str=', str);
const content = JSON.stringify({ a: 1, b: "1" });
let result = zlib.gzipSync(content);
},
// update (dt) {},
});